PHP Headers and Footers

PHP is an awesome tool I am just learning to use myself. But I wanted to share what I know of it with you as well. It makes editing your webpages so much easier :) PHP only works on servers that offer it, but most servers do nowadays so that really shouldnt be a problem :)

Take the current header area of any of your html pages.. If your pages are all in the same layout then I would suggest starting with HTML and ending with the body tag.. So you should be copying the following area of your webpage:

Most likely, you also have some scripts in there and the like that you want to have installed on all of your pages.. You can copy as much of your page as you like, but make sure it is only the code you want at the head of all of the webpages you are planning to converting to php :)

Now open Notepad and paste the code into it. Save it as header.php

Pretty easy right?

Now open any of your html pages in the same directory... Put the following code where the html through body tags are...

Save your page as "yourfilename.php".

You may have to upload it to your server in order to view it properly.
This is what your html code should look like now ..

This means all you have to edit with each new css based layout is the header.php file. It also means your pages will load faster since the header.php file will already be stored in your visitors cache.. You can also do this with anything you want to appear any where at all on each of your pages.. I use a footer.php file for my copyright information..

Just remember to provide the full path to your header.php and footer.php files, just as you would an image or they won't show up :)

Combining PHP includes, and cascading style sheets, makes changing layouts and load time much much faster :)

~Link Hearts Enchanted~

Links are definitely appreciated! Please feel free to right click to save one of these images to your hard drive and link them back to:
http://www.heartsenchanted.com

Thanks for your support!

Hearts Enchanted Logo

468x60 link logo

Home