"/>
Home / CSE / PHP - CS :: Discussion

Discussion :: PHP - CS

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

    <?php

    $x = 5;

    function fun()

    {

    $x = 10;

    echo "$x";

    }

    fun();

    echo "$x";

    ?>

  2. A.

     0

    B.

     105

    C.

     510

    D.

     Error

    View Answer

    Workspace

    Answer : Option B

    Explanation :

    First when the function is called variable x is initialised to 10 so 10 is printed later the global value 5 is printed.


Be The First To Comment