PHP - Functions
What is the issue with this PHP code?
$total = 5;
function addOne() {
$total = $total + 1;
}
addOne();
echo $total;
$total = 5;
function addOne() {
$total = $total + 1;
}
addOne();
echo $total;
$total is treated as a local variable but is used before initialization.global keyword$total, the function must declare global $total;.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions