What are the best practices for loading external functions only when needed in PHP?

To load external functions only when needed in PHP, you can use PHP's `require_once` or `include_once` functions to include the external file only when the function is called for the first time. This helps in optimizing the performance of your application by loading external functions only when they are actually needed.

function myFunction() {
    require_once 'external_functions.php';
    // Call the external function here
}