Home / CSE / PHP - CS :: Discussion

Discussion :: PHP - CS

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

    <?php

    function fun()

    {

    static $x = 0;

    echo $x;

    $x++;

    }

    fun();

    fun();

    fun();

    ?>

  2. A.

     012

    B.

     123

    C.

     111

    D.

     Error

    View Answer

    Workspace

    Answer : Option A

    Explanation :

    When static is used, each time the function is called, that variable will still have the information it contained from the last time the function was called.


Be The First To Comment