Home » PHP » PHP Functions » Question
  1. What will be the output of the following PHP code ?
    <?php 
    $p = 45;
    $q = 26;
    function add()
    {
    $GLOBALS['r'] = $GLOBALS['p'] + $GLOBALS['q'];
    }
    add();
    echo $r;
    ?>

    1. Error
    2. 45
    3. 26
    4. 71
    5. None of these
Correct Option: D

r is a variable present within the $GLOBALS array, it is also accessible from outside the function!



Your comments will be displayed only after manual approval.