anantamu.com


PHP Superglobals


Superglobals are in all scopes.


1.$GLOBALS

2.$_SERVER

3.$_GET

4.$_POST

5.$_FILES

6.$_COOKIE

7.$_SESSION

8.$_REQUEST

9.$_ENV


1.$GLOBALS

<?php
 function test() {
    echo 'current scope: ' . $GLOBALS['zoo'];
}
$zoo = "Example content";
test();
 ?>

Result: current scope: Example content



2.$_SERVER

It gives the server environment information,like server file name and server related information.

<?php
      echo $_SERVER['SERVER_NAME'];
?>

Result :anantamu.com



3.$_GET

It gets the values from GET method, get values display in url.


<html>
<head>
</head>
<body>
<form name='sample' id='sample' method='GET'>
<input type='text' name='user' value='test'>
<input type='submit' name='submit' value='submit'>
</form>
</body>        
</html>

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



3.$_POST

It sends the data through body, It is secure and hidden post the value.


<html>
<head>
</head>
<body>
<form name='sample' id='sample' method='POST'>
<input type='text' name='user' value='test'>
<input type='submit' name='submit' value='submit'>
</form>
</body>        
</html>

Result of $_POST['user']:test



3.$_REQUEST

It contains the contents of $_GET, $_POST and $_COOKIE.



List of All 223 Banks



Bank IFSC CODE