Welcome to WebmasterServe!

FREE TO JOIN! Join us now to engage in informative and friendly discussions about Webmastering, SEO, SEM, Internet Marketing, Programming, Graphic Design, Online Jobs and more. What are you waiting for? Ready to join our friendly community? It takes just one minute to register.

Dismiss Notice

Join WebmasterServe Forums 
Join the discussion! Have a better idea or an opinion? It takes just one minute to register Click Here to Join

Help Me/Question Php Global Variable

Discussion in 'PHP Programming' started by justiinn, Feb 17, 2016.

  1. justiinn

    Yellow Belt

    Joined:
    Feb 3, 2016
    Messages:
    161
    Ratings:
    +28 / -0
    php is very useful in making interactive web pages. superglobals are predefined variables that is you can use it any time whenever required.it was introduced in version 4.1.0.it 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?
     
  2. RADHESHYAM GUPTA

    Yellow Belt

    Joined:
    Feb 13, 2016
    Messages:
    362
    Ratings:
    +20 / -0
    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
    <?php
    $a = 20;
    $b = 15;
    function addition() {
    $GLOBALS['c'] = $GLOBALS['a'] + $GLOBALS['b'];
    }
    addition();
    echo $c;
    ?>
     

Share This Page