"> What will be the output of the following PHP code ?<?php$n

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

The check happens after the increment,thus it prints until n = 5.



Your comments will be displayed only after manual approval.