PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Globals are globals, that cannot be changed. $GLOBALS["foo"] is a geniune alternative to accessing $foo in the global namespace. No hacks there. What register_globals does is takes items from the superglobals $_POST, $_GET, $_REQUEST... and adds them to the global namespace directly so $_POST["foo"] is available as just $foo in the global namespace.
<?php
$myvar1 = 'This is my variable. This is global';
function dummyTest()
{
$myvar2='This is a local variable (scope only in this function)';
echo $myvar1; // Produces no output and a php warning
return $myvar2;
}
echo $myvar1; // prints out as not in function and declared globally
echo $myvar2; // Produces no output and a php warning as the variable is defined in the function and is local to that function.
echo dummyTest(); // prints out the value of $myvar2 as it is returned from the function.
?>