Home » PHP » PHP Variables » Question
  1. What will be the output of the following PHP code ?
    <?php
    $p=7;
    function calc()
    {
    echo $GLOBALS['p'];
    $GLOBALS['p']++;
    }
    calc();
    calc();
    calc();
    ?>
    1. 7
    2. 789
    3. 78
    4. 89
    5. None of these
Correct Option: B

Since, we are using $GLOBALS[‘p’].



Your comments will be displayed only after manual approval.