LIGHTENING YOUR WORKLOAD WITH INCLUDES 15. Navigate back (Web server type)

LIGHTENING YOUR WORKLOAD WITH INCLUDES 15. Navigate back to contact.php, and you ll see that the page title is still derived cor rectly from the page name. 16. There s one final refinement you should make. The PHP code inside the If $title doesn t exist, the echo command will be ignored, leaving just the default site title, Japan Journey. You can check your code against an updated version of index.php in index03.php in the download files. Creating pages with changing content So far, we ve looked at using PHP to generate different output depending on the page s filename. The next two solutions generate content that changes independently: a copyright notice that updates the year automatically on January 1 and a random image generator. PHP Solution 4-5: Automatically updating a copyright notice Continue working with the files from the previous solution. Alternatively, use index02.php and includes/footer.inc01.php from the download files for this chapter. If using the download files, remove the numbers from the filenames when moving them into your working site. 1. Open footer.inc.php. It contains the following XHTML:

The advantage of using an include file is that you can update the copyright notice throughout the site by changing this one file. However, it would be much more efficient to increment the year automatically, doing away with the need for updates altogether. 2. The PHP date() function takes care of that very neatly. Change the code like this:

103
In case you need quality webspace to host and run your web applications, try our personal web hosting services.

Leave a Reply