When should the require statement be used instead of the include statement in PHP, and why is it important for essential files?

The require statement should be used instead of the include statement in PHP when you want to include a file that is essential for the script to run. This is important because if the required file is not found, the require statement will halt the script execution and throw a fatal error, ensuring that the essential files are included properly. On the other hand, the include statement will only produce a warning and continue script execution if the file is not found.

// Using require statement to include an essential file
require 'essential_file.php';