Help Me/Question Php Global Variable


Well-Known Member
php is very useful in making interactive web pages. superglobals are predefined variables that is you can use it any time whenever was introduced in version is denoted by$.
there are different types of global variables-$globals,$server,$request,$cookie etc..
i dont know its use and cant use it in my codes.
will you explain me?


White Belt
There are so many predefined variable in Php, All predefined variable is known as super global variable.
It means it access from anywhere in php program such as out of class, out of function.
Here some Super global variable examples:-

  • $_GLOBAL
  • $_GET
  • $_POST
  • $_FILES
  • $_COOKIE
$a = 20;
$b = 15;
function addition() {
$GLOBALS['c'] = $GLOBALS['a'] + $GLOBALS['b'];
echo $c;