What are common pitfalls when trying to include external files in PHP scripts?

Common pitfalls when trying to include external files in PHP scripts include using incorrect file paths, not properly handling errors when the file cannot be included, and potential security risks if including files from user input. To solve these issues, always use absolute file paths, check for errors when including files, and avoid including files based on user input.

<?php
// Correct way to include an external file using absolute file path
include_once(__DIR__ . '/external_file.php');
?>