If a function is defined in the same file, but after the call to that function, there is no problem.
However if a function is defined in a different file and this file is included after the function call, a fatal error occurs. Fatal error: Call to undefined function func() in..
This is a more academic question than anything, because the best practice to to always define the function prior to calling it.
PHP Code:
<?php
// THIS DOESN'T WORK
echo func();
require('func.php'); // includes the func() definition
exit;
PHP Code:
<?php
// THIS DOES
echo func();
function func() {
return 'test';
}
exit;
Bookmarks