
Originally Posted by
SteveRDun
I've decided to use Javascript.
I can only say that you've made a bad decision, but then it's yours to make.
Can someone explain to me how exactly to use PHP or SSI to do the same thing?
There isn't really a lot to it. Create a file that contains a fragment of HTML (just that which you'd otherwise have to copy into every applicable HTML file), and place that file somewhere easily accessible. You'd then insert one of the statements in my previous post, adjusting the path as appropriate.
For example (taking the SSI route), with the file, example.inc:
Code:
<ul class="navigation">
<li><a href="/">Home</a></li>
<li><a href="/products/">Products</a></li>
<li><a href="/support/">Support</a></li>
<li><a href="/about-us/">About Us</a></li>
</ul>
and the served file, example.shtml:
Code:
<!DOCTYPE html PUBLIC ...>
<html lang="en">
<head>
<!-- ... -->
</head>
<body>
<div id="header">
<h1>My Site</h1>
<!--#include virtual="./example.inc" -->
</div>
<!-- ... -->
</body>
</html>
the client would receive:
Code:
<!DOCTYPE html PUBLIC ...>
<html lang="en">
<head>
<!-- ... -->
</head>
<body>
<div id="header">
<h1>My Site</h1>
<ul class="navigation">
<li><a href="/">Home</a></li>
<li><a href="/products/">Products</a></li>
<li><a href="/support/">Support</a></li>
<li><a href="/about-us/">About Us</a></li>
</ul>
</div>
<!-- ... -->
</body>
</html>
Any changes that you make to example.inc would be automatically reflected in all files that include it.
There is a difference between PHP and SSI when it comes to the treatment of paths. SSI acts at a URL level, whilst PHP operates from the filesystem. This means that
Code:
<!--#include virtual="/path/to/file.ext" -->
would resolve to the resource at
  http://www.example.com/path/to/file.ext
whereas
Code:
<?php
include "/path/to/file.ext";
?>
would resolve to the file at
  /path/to/file.ext
on a Linux system, or
  C:\path\to\file.ext
on a Windows system (assuming the DocumentRoot directive [or equivalent] points to a directory on the C: drive).
Relative paths are usually the same with both, though PHP introduces the concept of a 'working directory' and an include_path directive (much like the PATH environment variable).

Originally Posted by
Twey
Too much C, Mike?

It doesn't help that I'm not used to hashes as comment delimiters in programming languages. Weren't C and C++ -style comments enough for them? 
Mike
Bookmarks