First, notice that this file name's extension is .shtml, not .htm or .html. The reason is that server-side includes work only in files with a .shtml extension. This is why I had to put this information in this file and not in my HTML primer main file, which has a .html extension.
A server-side include can access a variable value that a server includes in an HTML file before it sends it to the requestor. You can insert an include statement in the HTML file that looks like this:
and the server will replace the statement with the last-modified date for the file. There are several environment variables that an operating system can keep track of and that can be accessible to a server program. Below is a partial list, but keep in mind that some or all of them might not work, depending on the server that is sending this file to you.
LAST_MODIFIED = Friday March 25 2011
SERVER_ADDR = Variable 'SERVER_ADDR' cannot be found
SERVER_NAME = benbrew.com
SERVER_PORT = 80
HTTP_HOST = benbrew.com
DATE_LOCAL = Wednesday August 15 2018
DATE_GMT = Wednesday August 15 2018
USER_NAME = Variable 'USER_NAME' cannot be found
Another thing that can be done with server-side includes is define "virtual" statements in another file. For example, the following statement
would be replaced with whatever text is located in the file "myvirtualfile.txt". This is a very useful feature for information that appears in many places and is subject to change. For example, if you put your E-mail address at the bottom of every one of your HTML files, then you would have to edit every single file whenever your E-mail address changes. This problem can be eliminated with server-side includes: rather than an E-mail address, each HTML file can contain a virtual statement, with the statement being defined in one file, so that if your E-mail address changes, you will have only to edit that one file. Below you will see an E-mail address that was produced this way.
Note that if the server that is sending this file to you translated the server-side include statements in this file correctly, you cannot see them in their original form. Even if you view the page source for this file, you will see the result after translation. This is why I forced two examples (LAST_MODIFIED and "myvirtualfile.txt") to appear in their original form.
Also note that .shtml files must be sent through a server in order to work. This means that when you edit your files on your home computer, merely opening them in a browser will not show you the desired result. You must copy the files to a server and access them from that server in order for the proper results to occur.