Home » PHP » PHP Variables » Question
  1. What will be the output of the following PHP code ?
    <?php
    static $n = 5;
    function calc()
    {
    echo $n;
    $n++;
    }
    calc();
    calc();
    calc();
    ?>
    1. 0
    2. 5
    3. Undefined variable: n
    4. 5 and 0
    5. None of these
Correct Option: C

Since variable n is not defined inside the function fun(), nothing will be printed.



Your comments will be displayed only after manual approval.