Example
Use a global variable in a function:
html
<?php
$x = 5;
function add($y) {
global $x;
return $x + $y;
}
echo "$x + 5 is " . add(5);
?>
Definition and Usage
The global keyword imports variables from the global scope into the local scope of a function.