PHP Conference Kansai 2025

Voting

: max(six, three)?
(Example: nine)

The Note You're Voting On

chris at candm dot org dot uk
3 years ago
The confusion expressed in some of the submissions here arise because functions declared outside conditional blocks are defined as the code is loaded and are thus callable and exist wherever in the code they are declared, whereas those declared inside a condition block are not defined until that block is executed. Thus:

echo foo();
function foo() { return "I am foo"; }

yields : "I am foo"

however because those inside a conditional are defined as they are encountered during code execution

echo foo();
if(true) {
function foo() { return "I am foo"; }
}

yields: Fatal error: Uncaught Error: Call to undefined function foo()

<< Back to user notes page

To Top