PHP - Request Lifecycle
What will be the output of this PHP code?
$count = 5;
function increment() {
global $count;
$count++;
}
increment();
echo $count;
$count = 5;
function increment() {
global $count;
$count++;
}
increment();
echo $count;
global $count; which means it uses the global variable $count defined outside.$count starts at 5, the function increments it by 1, so $count becomes 6. Then echo $count; prints 6.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions