Complete the code to access the global variable inside the function.
<?php $number = 10; function showNumber() { global [1]; echo $number; } showNumber(); ?>
The global keyword is used to access the global variable $number inside the function.
Complete the code to access the global variable using the $GLOBALS array.
<?php $value = 5; function printValue() { echo [1]['value']; } printValue(); ?>
$GLOBALS.$GLOBALS.The $GLOBALS array holds all global variables and can be used to access them inside functions.
Fix the error in the code to correctly access the global variable inside the function.
<?php $count = 3; function showCount() { [1]; echo $count; } showCount(); ?>
To access the global variable inside the function, declare it with global $count; before using it.
Fill both blanks to create a function that modifies a global variable.
<?php $score = 0; function increaseScore() { global [1]; [2]++; } increaseScore(); echo $score; ?>
To modify a global variable inside a function, declare it with global $score; and then increment it with $score++;.
Fill all three blanks to access and modify a global variable using $GLOBALS.
<?php $count = 1; function addCount() { [1]['count'] = [2]['count'] + [3]; } addCount(); echo $count; ?>
$GLOBALS.Use $GLOBALS to access the global variable count and add 1 to it inside the function.