Examples

Standard server variables

Echoing server variables in your HTML document is a way to provide dynamic content without resorting to CGI programming. For example, in the paragraph below I used <!--#echo var="http_host" --> and <!--#echo var="date_gmt" --> to supply my domain name and the current Greenwich Mean Time:

Hello and welcome to kgraff.net on Sunday, 19-Nov-2017 06:29:01 GMT .

A Perl CGI alternative for date and time display and manipulation.

If you click your browser's Reload or Refresh button, the displayed time will update.

Syntax:   <!--#echo var="VARIABLE_NAME" -->

Note:  Some servers require the variable names to be in ALL CAPS. Which server variables you can use, the ones in the table below with server responses other than (none) for my site, depends on how your hosting supplier configured the web server software, Apache in this case. Some servers require an .shtml extension in pages that call environment variables.

Below are selected enviroment variables and the response on this server. See the documentation for the web server software used on your site for a full list of available variables.

variable name server response
date_local Saturday, 18-Nov-2017 22:29:01 PST
date_gmt Sunday, 19-Nov-2017 06:29:01 GMT
document_name env_var.shtml
document_root /home/kgraff/kgraff.net
document_uri /it/tutorial/env_var.shtml
gateway_interface CGI/1.1
http_cache_control (none)
http_connection (none)
http_host kgraff.net
http_user_agent CCBot/2.0 (http://commoncrawl.org/faq/)
last_modified Saturday, 24-Jul-2010 16:30:13 PDT
remote_addr 54.162.164.86
request_method GET
request_uri /it/tutorial/env_var.shtml
script_filename /home/kgraff/kgraff.net/it/tutorial/env_var.shtml
script_name /it/tutorial/env_var.shtml
script_uri http://kgraff.net/it/tutorial/env_var.shtml
script_url /it/tutorial/env_var.shtml
server_addr 66.33.196.254
server_name kgraff.net
server_port 80
server_protocol HTTP/1.0
server_software Apache
web design * database * Macintosh OS X * Linux * UNIX