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 Thursday, 03-Apr-2025 15:54:11 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 | Thursday, 03-Apr-2025 08:54:11 PDT |
date_gmt | Thursday, 03-Apr-2025 15:54:11 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 | no-cache |
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 | 3.145.200.81 |
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 | https://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 | 443 |
server_protocol | HTTP/2.0 |
server_software | Apache |