How does the require function differ from the include function in PHP?

The main difference between the require and include functions in PHP is how they handle errors. When using require, if the file being included is not found, a fatal error will occur and the script will stop executing. On the other hand, include will only produce a warning and allow the script to continue running. It is important to choose the appropriate function based on whether the included file is essential for the script to run correctly or not.

// Using require function
require 'file.php';

// Using include function
include 'file.php';