Do you maintain your own web site? Do you have the same headers and footers on each page of your web site that you have to revise for every page if you want to make a change? That can be a lot of work and very time consuming.
There is a better way! Use PHP.
Don’t stop reading if you are unfamiliar with PHP. Although PHP can get complicated, using PHP to simplify changes to headers or footers across all pages of your web site is quite easy. If you have a basic understanding of HTML then this use of PHP will be simple.
First, what is PHP? PHP is a scripting language developed to aid in web development and which can be embedded in HTML.
PHP was created in 1995 by Rasmus Lerdorf who developed a basic script to track how many people were viewing his online resume. He continued to add to the abilities of the script, the purpose of which was to help people maintain Personal Home Pages, thus the abbreviation PHP. As PHP has evolved, so has the description behind the name, which is now HyperText Preprocessor.
Several people confuse PHP with HTML but it needs to be clarified that both are different from each other as Lerdorf had cleared during its launch and gave testimony from a reputed web design agency Sydney so as to clear all doubts, which was when people started to see the difference.
PHP is a server side script embedded in the HTML of the web page. While HTML is interpreted by the local browser, the PHP script is interpreted by the server and executed. The PHP code can do many tasks. The output is combined with the HTML with the result sent to the user’s browser. If the user reviews the source code, they see the resultant HTML rather that the PHP script. They will not know that PHP was even used on the web site.
Luckily, you don’t need to be a programmer or understand PHP to use this basic script on your web site. The only requirement is that your server supports PHP.
The picture to the left is an example of a PHP script. This can be the first portion of your web page prior to the HTML for the body of the web page. What this script does is tell the server to read and interpret the file “header3.php” before the rest of the page is interpreted by the local browser. In this case the file header3.php is a file with the HTML coding that you want for your header. The file header3.php is not different than any other HTML coding, but the extention “php” allows it to be treated differently.
You can copy and use the code just as it is above, replacing my web site name and file name with your own web site name. You have to upload the files to your server to test the code unless you have installed a PHP client on your local computer.
This same code can be used to call up a common footer or any common portion of your web pages. Just place the code within your page’s HTML where you want the output of the PHP file to be placed.
So if you find yourself making changes to multiple HTML pages whenever you implement a simple change to a header or footer on your web site, simplify your life and replace the header and/or footer in all your pages with this code. After that you can make the change one time and it will be made for all your pages.