The include() and require() functions are both used to include a file into the current PHP script.

The main difference between them is how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. include(), on the other hand, will only produce a warning (E_WARNING) and the script will continue.

Example:

// Include the file
include(‘myfile.php’);

// Require the file
require(‘myfile.php’);

Leave a Reply

Your email address will not be published. Required fields are marked *