Home » PHP » PHP While Loops » Question
  1. What will be the output of the following PHP code ?
    <?php
    $p = 0;
    while ($p++)
    {
    print $p;
    }
    print $p;
    ?>
    1. Error
    2. 0
    3. 1
    4. Nothing
    5. None of these
Correct Option: C

As it is a post increment, it checks and then does not enter the loop, thus prints only 1.



Your comments will be displayed only after manual approval.