Server-side includes? Not for me!
When I first started out as a web designer, I kept clear from the advice of senior designers and refused to venture into any form of coding that wasn’t standard HTML; If a file didn’t end with a .htm or .html, I wouldn’t go near it.
This, I found out later, was not only a significant limitation in my development as a web designer, but also cost me dearly in time and the patience of my clients.
One good example of my time wasting
I would use standard HTML (even then I avoided frames like the plague!) to create a menu system which would be repeated on every page of a website. If I needed to change a link or any other repetitive and consistent aspect of the design of the menu, I would need to open up each page and copying and paste the amended code…very time consuming.
To cut a long story short, I eventually swallowed my pride and learnt a little about an amazing language called PHP. All I needed to do to make a start was to save each page of a site with the .php extension instead of .html. I could then incorporate saving PHP code into that page.
This revolutionised the way in which I worked. For instance, instead of having to copy my menu system from page to page (repeating the same code over and over again), I created something called a php ‘Server-side include’ to ‘load’ a single file containing that menu code into each page.
PHP Include Example
include(“../menus/menu.html”) // this is the relative file location of my menu – no absolute addresses
As you can see from the above example, all I needed to do for each page is refer, via the include command in PHP, to an individual file stored at a specific location on my server. The contents of that file would then load itself into my page at the position it was called upon via the include command by the server. The other thing is ensure that the page holding this PHP code was as a .php file.