include() function:
This function is used to copy all the contents of a file called within the function, text wise into a file from which it is called. This happens before the server executes the code.
Example: This example is using the include() function in PHP.
<?php
// File to be included
echo “Hello GeeksforGeeks”;
?>
Now, try to include this file into another PHP file index.php file, and will see the contents of both the file are shown.
<?php
include(“even.php”);
echo “<br>Above File is Included”
?>
Output:

require() function:
The require() function performs the same as the include() function. It also takes the file that is required and copies the whole code into the file from where the require() function is called.
Now, if we try to include this file using require() function into a web page we need to use an index.php file. We will see that the contents of both files are shown.
<?php
require(“even.php”);
echo “<br>Above File is Required”
?>
Output:
