Starting php script:
echo 'Lets make a global function';
function createglobal() {
global $my_global;
$my_global = 10;
}
$my_global = 5;
echo "The value of \$my_global is '$my_global'
";
createglobal();
echo "The value of \$my_global is '$my_global'
";
ending php script
Before the createglobal(); is called the value of variable stays to local value. Which is 5. But as soon as the function is called the value becomes to 10 which was defined in the createglobal function.