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

The value of global variable y does not change therefore it’ll print 25;



Your comments will be displayed only after manual approval.