Home » PHP » PHP For Loops » Question
  1. What will be the output of the following PHP code ?
    <?php
    $p = 0;
    for(++$p; ++$p; ++$p)
    {
    print $p;
    if ($p == 6)
    break;
    }
    ?>
    1. Error
    2. 2
    3. 24
    4. 246
    5. None of these
Correct Option: D

The order of execution is initialization, check, increment/decrement, check, increment/decrement, check, increment/decrement….so on.



Your comments will be displayed only after manual approval.