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 Friday, 19-Apr-2024 15:39:51 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 Friday, 19-Apr-2024 08:39:51 PDT
date_gmt Friday, 19-Apr-2024 15:39:51 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 Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
last_modified Saturday, 24-Jul-2010 16:30:13 PDT
remote_addr 18.189.170.17
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 69.163.176.66
server_name kgraff.net
server_port 80
server_protocol HTTP/1.1
server_software Apache
web design * database * Macintosh OS X * Linux * UNIX