Superglobals are in all scopes.
1.$GLOBALS
2.$_SERVER
3.$_GET
4.$_POST
5.$_FILES
6.$_COOKIE
7.$_SESSION
8.$_REQUEST
9.$_ENV
<?php function test() { echo 'current scope: ' . $GLOBALS['zoo']; } $zoo = "Example content"; test(); ?>
Result: current scope: Example content
It gives the server environment information,like server file name and server related information.
<?php echo $_SERVER['SERVER_NAME']; ?>
Result :anantamu.com
It gets the values from GET method, get values display in url.
Result of $_GET['user']:test
It is used to get the variable name values in the URL.
<?php echo 'Welcome ' .$_GET["name"]; ?>
Assuming the user URL is http://google.com?name=Programmer
Result Welcome Programmer
It sends the data through body, It is secure and hidden post the value.
Result of $_POST['user']:test
It contains the contents of $_GET, $_POST and $_COOKIE.