PHP - Functions
Identify the error in the following PHP code and select the correct fix:
$count = 0;
function increment() {
$count++;
}
increment();
echo $count;$count = 0;
function increment() {
$count++;
}
increment();
echo $count;$count, but without global, it treats $count as undefined local variable.global $count; inside the function tells PHP to use the global $count variable, allowing increment to work.global $count; inside the function. -> Option B15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions