What are the differences between using require and include in PHP when including files?

When including files in PHP, the main difference between using require and include is how they handle errors. require will produce a fatal error and stop the script if the file cannot be included, while include will only produce a warning and continue executing the script. It is generally recommended to use require when including files that are essential for the script to function properly, and include for files that are optional.

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

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