Home » PHP » PHP While Loops » Question
  1. What will be the output of the following PHP code ?
    <?php
    $n = 1;
    while(++$n || --$n)
    {
    print $n;
    }
    ?>
    1. 2345678......infinite time
    2. 12345678...........infinite time
    3. Error
    4. Nothing
    5. None of these
Correct Option: A

As it is || operator the second expression is not evaluated and n is always incremented, in the first case to 1.



Your comments will be displayed only after manual approval.