Use global scope variable in PHP
Description
The following code shows how to use global scope variable.
Example
<?// w ww .j a v a2 s .co m
$capital = "Washington DC";
function Nation()
{
global $capital;
printCity($capital);
}
function printCity($NameOfCity)
{
print("The city is $NameOfCity.<br>\n");
}
function California()
{
$capital = "Sacramento";
printCity($capital);
}
function Utah()
{
$capital = "Salt Lake City";
printCity($capital);
}
Nation();
California();
Utah();
Nation();
?>