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

Every time the function is called the value of n becomes 5, therefore we get 5 on every function call.



Your comments will be displayed only after manual approval.