Note: For this tutorial you'll need to strip out the asterik (*) placed within the php coding.
This form of PHP makes updating your main layout mostly painless. When you do a new design, you only have one file to to update instead of each and every page of content. Why is this better than SSI? It's not such a load on your server is the way I see it.
Start off by taking a completed html file, save two copies of it somewhere on your hard drive. Name one of them "content.html" and the other "index.php"
Take the file you named "content.html" and strip out the layout. You'll need to leave text formatting, such as line breaks, bold, italics, underlines, and hyperlinks. This file shouldn't have body tags either, just your content formatted as you wish. Save the file then open "index.php" and strip out the content.
Still working in "index.php" - directly under your ending head tag, place the following strip of code:
<*?php if ($x == "") { $x = "content.html"; } ?>
Find where you want the content to show up in the layout, and place in this chunk of code:
<*?php
$dir = "/root/path/to/directory";
$full = "$dir/$x";
$full = ereg_replace("../","/",$full);
if (file_exists("$full")){
include("$full");
}
else{
echo "File: $full does not exist";
}
?>
Now, in that chunk find where it says "root/path/to/directory" (/hsphere/local/home/[username]/[domainname.com] - Hostiva) and change it to your path, if you don't know this you can usually find it in your server FAQ. If you're using this for a directory other than the main, say yourdomain.com/log, make sure the path is "root/path/to/directory/log"
To link to the rest of your content, do the same to them as you did for content.html, then link them as so:
<a href="?x=pagename.html">
Upload these files to a test directory to make sure they work, trying to view them on your local machine will only work if special modules are installed. Once they're online and working, make sure you're blocking access to sensitive files, try to view yourdomain.com/?variable=/etc/passwd, if done correctly this should bring up "file does not exist" text.