The include statement includes an external file with php code into the program. So, for example, let’s define the hello.php file.
Let’s create a file for an example, call it hello.php and add the code below:
$age = 24;
Now let’s attach this file to our main one and use the $age variable:
include "hello.php";//include our file $name = "Ben"; echo $name . '=' . $age;
When the file is not found include will issue an error, require will issue a warning but execute the code.
require "hello.php";//include our file
include once, require once
include the file only once:
include once "hello.php"; require once "hello.php";
In large applications, the number of included files can be quite large. However, the built-in function spl_autoload_register()