|
It's high time you jump on the "includes" band-wagon! You're missing out on something so easy and simple to implement that could have saved you from replacing that "one word" in your menu on 20 different pages!!
The best option is to use the PHP include() function. It's so simple to implement, you will be hitting yourself for not asking earlier.
The Syntax
<?php include('directory/file.php'); ?>
How to use it
Here's your index.php file (note that all your files using the php include() function must have the .php extension)
...
<body>
<?php include('navigation.inc'); ?>
<div id="content">....</div>
</body>
And this would be your navigation.inc file (note that your included file can have the extension you want – .html, .php, .inc, .whatever)
<ul>
<li><a href="home.php">Home</a></li>
<li><a href="services.php">Services</a></li>
<li><a href="contact.php">Contact</a></li>
</ul>
There's is also the SSI version (Server-Side Includes). It is also the same syntax for ASP includes
The Syntax
Using a virtual path (most commonly used)
<!––#include virtual="/directory/page.html" ––>
Using a relative path
<!––#include file="page.html" ––>
How to use
Here's your index.shtml or index.asp file (note that all your files using the SSI or ASP include function must have either the .shtml or .asp extension)
...
<body>
<!––#include virtual="/navigation.inc" ––>
<div id="content">....</div>
</body>
And this would be your navigation.inc file (note that your included file can have the extension you want - .html, .asp, .inc, .whatever)
<ul>
<li><a href="home.shtml">Home</a></li>
<li><a href="services.shtml">Services<</a></li>
<li><a href="contact.shtml">Contact</a></li>
</ul>
|