What are the potential pitfalls of using include_once() in PHP functions and how can they be avoided for better code readability?

Using include_once() within PHP functions can lead to unexpected behavior if the included file contains function declarations or variable definitions that are already present in the calling script. This can result in redeclaration errors or conflicts. To avoid this issue and improve code readability, it is recommended to include the necessary files outside of the function scope.

// Include the necessary file outside of the function scope
include_once 'file_to_include.php';

// Define the function
function myFunction() {
    // Function code here
}