How can the use of require_once() in PHP lead to the display of script content instead of execution on a webpage?

When using require_once() in PHP, if the file being included does not exist or cannot be found, it can lead to the display of script content instead of execution on a webpage. To solve this issue, you should check if the file exists before including it using require_once(). This way, you can prevent the display of script content and ensure that the file is included properly.

$file = 'include_file.php';

if (file_exists($file)) {
    require_once $file;
} else {
    // Handle the case when the file does not exist
    echo 'File not found';
}