Here comes a thread which hopefully will have me laughing in years to come due to the simplicity of it. What's more, it's the only PHP Tutorial thread which comes to you with... theme music!
(Altogether now...) Learning PHP, I think I'm learning PHP, I really think so...
Step 1 - Using include
The main reason I got into using PHP in the first place was because I got tired of having to replace one item in the every file within a site, e.g. when you add one item onto a menu.
The way around this is to use the include command.
So if you were to add something onto that menu you might want to create a menu.php file, which can be pure html if you want.
Then call the file in each file by using the following line:
(N.B. You should use $DOCUMENT_ROOT to get to your file. You can put the http:// path but it can create problems)
To make future changes just change the menu.php file.
(Altogether now...) Learning PHP, I think I'm learning PHP, I really think so...
Step 1 - Using include
The main reason I got into using PHP in the first place was because I got tired of having to replace one item in the every file within a site, e.g. when you add one item onto a menu.
The way around this is to use the include command.
So if you were to add something onto that menu you might want to create a menu.php file, which can be pure html if you want.
PHP:
<a href="link1.php">Link 1</a> |
<a href="link2.php">Link 2</a> |
<a href="link3.php">Link 3</a>
PHP:
...
<?php
include ("$DOCUMENT_ROOT/menu/menu.php");
?>
...
To make future changes just change the menu.php file.