Complete the code to access the global variable inside the function.
<?php $number = 10; function showNumber() { global [1]; echo $number; } showNumber(); ?>
In PHP, to access a global variable inside a function, you use the global keyword followed by the variable name without the $ sign.
Complete the code to modify the global variable inside the function.
<?php $count = 5; function increment() { global [1]; $count++; } increment(); echo $count; ?>
To modify a global variable inside a function, you must declare it as global without the $ sign.
Fix the error in the code to correctly access the global variable inside the function.
<?php $value = 20; function display() { echo [1]; } display(); ?>
To access a global variable inside a function without declaring it global, use the $GLOBALS array with the variable name as a string key.
Fill both blanks to create a function that modifies a global variable using the $GLOBALS array.
<?php $score = 0; function addPoint() { [1]['score'][2]; } addPoint(); echo $score; ?>
Use the $GLOBALS array to access the global variable and the increment operator ++ to increase its value.
Fill all three blanks to create a function that resets a global variable to zero using the global keyword.
<?php $counter = 10; function resetCounter() { global [1]; [2] = [3]; } resetCounter(); echo $counter; ?>
Declare the variable as global without the $ sign, then assign zero to the variable with the $ sign.