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

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.



Your comments will be displayed only after manual approval.