PHP includes is server side language which means to "include" or "gather" from another source.
For this tutorial we will have two files: "index.php" and "example.php"
Make the contents of example.php:
Make the contents of index.php:
Code:
<?php include("example.php"); ?> This code opens by stating it will use a PHP function [include]. The file is enclosed in brackets and speech marks making it clear which file will be included. Then the function is closed at the end of the include as we no longer need PHP accessible on this webpage.
When index.php is opened, it will show the contents of example.php
This can be done with a large variety of file types.
Most people use this so they only have to update one file instead of many that may be linked to it, for example a navigation menu - you may need to add a single link, where you would have to update each page normally, we could simply edit the one file "Menu.php" and include the other link.