What is the difference between require and include in PHP?

In PHP, both require and include are used to include files in a PHP script. The main difference between them is how they handle errors. If the file being included is not found, require will produce a fatal error and halt the script execution, while include will only produce a warning and allow the script to continue. It is generally recommended to use require when you want to ensure that a file is included and included only once, and use include when the file is not critical to the script execution.

// Using require to include a file
require 'filename.php';

// Using include to include a file
include 'filename.php';