What are best practices for including external files in PHP scripts and ensuring their proper execution?

When including external files in PHP scripts, it is best practice to use the include or require functions to ensure the files are properly executed. This helps in organizing code, reusability, and maintaining a modular structure. Additionally, using absolute paths or defining a base directory can prevent issues with file paths and ensure the correct files are included.

<?php
// Using include to include an external file
include 'path/to/external/file.php';

// Using require to include an external file
require_once 'path/to/external/file.php';
?>