Home » PHP » PHP Operators » Question
  1. What will be the output of the following PHP code ?
    <?php
    $p = 2;
    while ((--$p > ++$p) - 2)
    {
    print $p;
    }
    ?>
    1. 0000000000........infinite time
    2. 2222222.........infinite time
    3. -2-2-2-2-2-2-2-2.......infinite time
    4. All of above
    5. None of these
Correct Option: B

(–$p > ++$p) evaluates to 2 but -2 makes it enters the loop and prints p which is 2.



Your comments will be displayed only after manual approval.