You specifically asked about Server Side Includes, so I hope I'm not leading you in the wrong direction by writing about the PHP require() statement. A PHP require() statement will accomplish the same thing. If your web server has PHP enabled, you can give it a try.
Let's say you want a copyright line at the bottom of every page.
Put this code in the file that needs the copyright line --- in the place where the copyright line should appear:
require ('copyright.html');
?>
This file --- the file that will ultimately display the copyright line --- must have a .php extension, not an .html extension. You could call this file test.php.
Next, create the file "copyright.html". Even though this file has the .html extension, it is not a complete HTML file. It won't start or end with or have a
or tag. It will only contain the snippet of code you want to appear in place of the require() statement.
Therefore, the entire content of the file would be:
Copyright © 2007
To see if this works, add both files to your web server. The files should be side by side --- no file should be in a folder above or below the other file. (This can change as your technique advances.)
Call up test.php from your web server in your web browser. (This won't work on the files on yor local computer -- the files have to be on a web server with PHP enabled.) As the page is served to your website, the copyright line will dynamically appear. Now, when 2008 rolls around, it will be easy to make a site-wide change to your copyright line.
Also, as your technique advances, you can use longer snippets of code. If you wanted the sidebar of your site to be the same on every page, you could create a snippet of the entire sidebar and call it into every page with the require() statement.
2007-03-08 16:01:31
·
answer #1
·
answered by mason00000001 2
·
0⤊
1⤋
http://httpd.apache.org/docs/1.3/howto/ssi.html
This applies to most platforms, in addition to Apache - the basics of server-side includes are typically consistent across vendors.
2007-03-08 15:38:27
·
answer #2
·
answered by Rex M 6
·
1⤊
0⤋