PHP Solutions
Chapter 4
The theme of this chapter is includes. That is when various parts of a web page are "included" from an outside file.
This allows for the ability of changing one file across 100's of pages. Like a stylesheet for logic.
Solution Index
- PHP Solution 4-1
- Moving the navigation menu and footer to include files
The code responsible for the navigation and footer are in two separate files and called with the include method. - PHP Solution 4-2
- Testing the security of includes
There is a line of code which holds a password, because it's in PHP tags, it is not shown through View -> Source - PHP Solution 4-3
- Automatically settiing a style to indicate the current page
If you click on a link on the left-hand menu, the white indicator will change with the current page. - PHP Solution 4-4
- Automatically generating a page's title from its filename
Taking the filename and putting it into the Title tag. - PHP Solution 4-5
- Automatically updating a copyright notics
The copyright at the bottom of the page now displays the begin year and the currenty year. - PHP Solution 4-6
- Displaying a random image
Refreshing the home page will show the images are cycling. - PHP Solution 4-7
- Adding a caption to the random image
Using an associative array to display a caption along with an image. - PHP Solution 4-8
- Using includes with absolute pathnames
Luckily, my server supports this:$_SERVER['DOCUMENT_ROOT']