How can the include function in PHP help in managing errors in multiple files efficiently?

When working with multiple PHP files, managing errors efficiently can be challenging. By using the include function in PHP, we can easily include a file that contains error handling functions, making it easier to manage errors across multiple files.

// error_handling.php
function customErrorHandler($errno, $errstr, $errfile, $errline) {
    echo "<b>Error:</b> [$errno] $errstr<br>";
    echo "Error on line $errline in $errfile<br>";
}

set_error_handler("customErrorHandler");

// index.php
include 'error_handling.php';

// code that may generate errors