According to PHP manual calling a user-defined function prior to its definition doesn't produce an error except:
When a function is defined in a conditional manner... Its definition must be processed prior to being called.
Example:
bar();
$makefoo = true;
if ($makefoo) {
function bar() {
echo "I don't exist.
";
}
}
Throws a Fatal error:
Fatal error: Uncaught Error: Call to undefined function bar() in...
With above explanation I suppose below code to produce the same error:
foo();
bar();
function foo() {
$makefoo = true;
if ($makefoo) {
function bar() {
echo "I don't exist until foo() is called.
";
}
}
}
But it doesn't. What am I missing in manuals that describes this behavior?