Include and require are both used to include a file into the current one.

The main difference between include and require 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 will only emit a warning and the script will continue execution.

Example:

// Include
include ‘file.php’;

// Require
require ‘file.php’;

Leave a Reply

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