Web design portfolio - LIGHTENING YOUR WORKLOAD WITH INCLUDES 6. Open index.php,
LIGHTENING YOUR WORKLOAD WITH INCLUDES 6. Open index.php, and insert the following in the space left by the nav unordered list: 7. Save index.php and load the page into a browser. It should look exactly the same as before. Although the menu and the rest of the page are coming from different files, PHP merges them before sending any output to the browser. 8. Do the same with the footer
11. Save menu.inc.php and view the site again. The change is reflected on all pages. You can check your code against index02.php, menu.inc01.php, and footer.inc01.php. As Figure 4-2 shows, there s a problem with the code at the moment. Even when you navigate away from the home page, the style that indicates which page you re on doesn t change (it s controlled by the here ID in the tag). Fortunately, that s easily fixed with a little PHP conditional logic. Figure 4-2. Moving the navigation menu to an external file makes maintenance easier, but you need some conditional logic to apply the correct style to the current page. Before doing that, let s take a look at some important aspects of working with include files in PHP.
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.