What are the main differences between require and include in PHP?

The main differences between require and include in PHP are how they handle errors and how they include files. - require will cause a fatal error and stop the script if the file cannot be included, while include will only produce a warning and allow the script to continue. - require is generally used when the included file is essential for the script to run correctly, while include is used when the included file is optional. - require_once and include_once are similar to their counterparts, but they ensure that the file is only included once.

<?php
// Using require
require 'header.php';

// Using include
include 'footer.php';
?>