PHP include
Today id like to briefly mention the PHP include statement, please bear in mind that im a PHP newbie, previous to this I only wrote really simple scripts to run as a Flex backend for adding, deleting and updating database records. There are 4 types of includes:
- include
- include_once
- require
- require_once
Please see here for a detailed explanation of each.
While working on my main index.html page I wanted to reuse my code for the header and side navigation. So after implementing them I seperated them into a header.php and leftNav.php and used the include statement like so:
<?php include ("header.php"); ?>
This did not work, it took me sometime before realizing that in order for PHP commands to be processed by the index file, the extension had to be renamed to index.php. Please note, for users hosting with Dreamhost, they allow your landing page to be index.php. If your host does not allow this write a .htaccess file like so:
Options -Indexes
Redirect /index.html index.php
Place the file in the root of your site and it will direct all traffic to index.php.











