Home » PHP » PHP For Loops » Question
  1. What will be the output of the following PHP code ?
    <?php
    $s = 2;
    for (1; $s == 1; $s = 2)
    {
    print "In for loop statement executed...";
    }
    print "After for loop statement executed...\n";
    ?>
    1. After for loop statement executed...
    2. Error
    3. In for loop statement executed...
    4. Nothing
    5. None of these
Correct Option: A

The loop never exits as the condition ++s == s is always satisfied,evaluated from right to left.



Your comments will be displayed only after manual approval.