What are the potential pitfalls of embedding external scripts in PHP files, and how can they be avoided?

Potential pitfalls of embedding external scripts in PHP files include security vulnerabilities, code duplication, and difficulty in maintaining and updating the code. To avoid these pitfalls, it is recommended to use PHP's include or require functions to include external scripts in a separate file.

// Include external script using require_once
require_once 'external_script.php';