Does anyone know of a site that might cover how to make a template for site in PHP? I'm looking for something simular to what www.php.net has when you view php "source." I have the basic knowlege of PHP templates, but was wondering if there is something more complex.
Hmm, I don't fully understand what you mean, but you might be interested in using something called FastTemplate which is a feature in PHP I beleive. Check out php.net for more information or the book "Professional PHP Programming" by wrox explains about it a bit.
The way SitePoint does this is as follows. Forgive the simplicity of the design, but you should get the idea. :-)
First, we create a file called pageLayout.php. This is our template, and is responsible for the page layout that is common to all pages of our site:
<!-- pageLayout.php -->
<H1> SITE TITLE </H1>
<?php echo($content); ?>
Notice we have echoed a variable named $content in the above code. This variable should contain the content that we want to display on the page. But how does it get its value?
Well let's consider a page of our site. Call it samplePage.php. In this file, we will define the content to be displayed, then use pageLayout.php to display it:
<!-- samplePage.php -->
$content = '
<P>This is my site. It\'s built with PHP to make my life easier, but you don\'t have to know that!</P>
<P><A HREF="mailto:email@example.com">eMail me!</A></P>
Notice that all apostrophes (') in the content need to be escaped with backslashes (\') because the content is actually one big string, the beginning and end of which are marked by apostrophes.
The include() function tells PHP to insert the contents of pageLayout.php into the file. This slaps in our page layout, which uses our $content variable to fill the page.
Using multiple variables, you can build very flexible templates for your site.