In the PHP script provided, why is it necessary to include the function outside of the main function?

When including a function outside of the main function in PHP, it ensures that the function is defined before it is called within the main function. This is necessary because PHP reads code from top to bottom, so if a function is called before it is defined, it will result in a "function not found" error. By declaring the function before it is called, the main function can successfully utilize the defined function.

<?php

// Define the function outside of the main function
function myFunction() {
    // Function logic here
}

// Main function
function main() {
    // Call the defined function
    myFunction();
}

// Call the main function
main();

?>