What are the potential pitfalls of using require to include files in PHP scripts?

One potential pitfall of using require to include files in PHP scripts is that if the file being included does not exist or cannot be found, it will result in a fatal error and stop the script execution. To prevent this issue, you can use the file_exists function to check if the file exists before including it.

if (file_exists('path/to/file.php')) {
    require 'path/to/file.php';
} else {
    echo 'File not found';
}