What are the potential pitfalls of including functions within a loop in PHP scripts?

Including functions within a loop in PHP scripts can lead to performance issues as the function will be called multiple times unnecessarily. To solve this problem, it is recommended to define the function outside of the loop and then call the function within the loop.

// Define the function outside of the loop
function myFunction($value) {
    // Function logic here
}

// Loop where the function is called
foreach($array as $value) {
    myFunction($value);
}