PHP Include

(from Full Article)

The include command can save you a lot of time as you can create a header, place it in a file and just include that file on every page and the header will be shown. This will also mean that you do not need to edit every page every time you need to edit your header!

Basically the PHP Include command takes the file name and inserts the contents of the file into the script.

To illustrate this, I will use an example:

  1. Create a HTML file called Menu.html and insert the following code into it:
<ul>

<li>Home</li>

<li>Articles</li>

<li>Tutorial</li>

</ul>
  1. Now create a menu_example.php PHP file (in the same directory as Menu.html) and insert:
<?php

include(‘Menu.html’);

?>
  1. Navigate to menu_example.php in your browser and run it – you should see:
Shows the menu that is being included.
Menu Included.
Leave a comment

2 Comments.

  1. Hello from Russia!
    Can I quote a post in your blog with the link to you?