What are the best practices for including external scripts in PHP websites to ensure compatibility and functionality?

When including external scripts in PHP websites, it is important to ensure compatibility and functionality by properly handling errors, checking for script dependencies, and sanitizing input to prevent security vulnerabilities. One way to achieve this is by using the `require_once` or `include_once` functions to include external scripts, which helps prevent issues with duplicate script inclusions and ensures that dependencies are loaded only once.

<?php
// Include an external script using require_once
require_once('external_script.php');
?>