Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Printing Environment Variables with echo

May 8, 2000

echo
Echo prints the value of one of the environment variables.

DOCUMENT_NAME - Prints the file name of the current document.
<!--#echo var="DOCUMENT_NAME" -->

displays as:
index.html

DOCUMENT_URI - Prints the virtual path to the current document.
<!--#echo var="DOCUMENT_URI" -->

displays:
/YourDirectory/YourFilename.html

Ever go crazy trying to copy the "big guys" and have the full URL of your pages displayed on each and every page in your site? You won't last long if you're hardcoding this information; do it with an include and simplify your life! Precede the include with your domain name to display the full URL of any page.

http://YourDomain<!--#echo var="DOCUMENT_URI" -->

QUERY_STRING_UNESCAPED - The unescaped version of any search query the client sent, with all shell-special characters escaped with \.
<!--#echo var="QUERY_STRING_UNESCAPED" -->

DATE LOCAL - Dates and times are subject to the server timezone unless you've configured your server to show a different timezone. Default output of DATE_LOCAL is fairly blah, ranging to ugly but the good news is you're not stuck with the default output. By combining the variable with config timefmt you can specify almost any output you please.

Consider the following two examples. The first is the default output of DATE_LOCAL.

<!--#echo var="DATE_LOCAL" -->

displays as:
Saturday, 15-Apr-2000 12:24:42 MDT

Not exactly what you wanted, so let's customize it a bit. The example below uses the config directive to specify a more pleasing output. Text is added to the include giving us a line that flows like a sentence rather than just sticking the information up there for the world to see.

<!--#config timefmt="%A, the  %d of  %B, in the year  %Y" -->
<!--#echo var="DATE_LOCAL" -->

displays as:
Saturday, the 15 of April, in the year 2000 

DATE_GMT - DATE_GMT works the same as DATE_LOCAL, except that it returns Greenwich Mean Time.
<!--#echo var="DATE_GMT" -->

LAST_MODIFIED - The date the current file was last modified. This is another trick the "big guys" use. Don't worry yourself to death trying to remember to hand change your last modified date, let SSI take care of it for you! Simply add the following line to your HTML pages.
<!--#echo var="LAST_MODIFIED" -->

Includes
Server Side Includes
CGI Environment Variables


Up to => Home / Authoring / SSI / Intro




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers