PHP: Include
PHP gives the ability to include contents of other files in your current file. Therefore, it is a usual practise to create a header file and call it header.php and inclde it in all consecutive files to ensure that the header of all your website looks consitent.
Example:
header.php
|
<a href="home.php">home</a> <a href="tutorial.php">tutorials</a> |
Now, the contents of this header.php can be included in any other page. Example index.php is:
|
<html> <body> <?php include ("header.php"); ?> <p> Hi This is a practise page!! </p> </body> </html> |
Now, the user would see the following code:
|
<html> <body> <a href="home.php">home</a> <a href="tutorial.php">tutorials</a> <p> Hi This is a practise page!! </p> </body> </html> |
And the output would be:
This would give following output:
Same thing can be repeated for normal menus and footers.