Home / CSE / PHP - CS :: Discussion

Discussion :: PHP - CS

  1. What will be the output of the following PHP code ?

    <?php

    $x = 5;

    $y = 10;

    function fun()

    {

    $GLOBALS['y'] = $GLOBALS['x'] + $GLOBALS['y'];

    }

    fun();

    echo $y;

    ?>

  2. A.

     5

    B.

     10

    C.

     15

    D.

     Error

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    You can access the global variable using $GLOBALS[‘globalvariablename’].


Be The First To Comment