Examveda
Examveda

What will be the output of the following PHP code ?
<?php
$i = 0;
while ((--$i > ++$i) - 1)
{   
    print $i;
}
?>

A. 00000000000000000000….infinitely

B. -1-1-1-1-1-1-1-1-1-1…infinitely

C. no output

D. error

Answer: Option A

Solution(By Examveda Team)

(–$i > ++$i) evaluates to 0 but -1 makes it enters the loop and prints i.

This Question Belongs to PHP >> Control Structures(Loop In PHP)

Join The Discussion

Related Questions on Control Structures(Loop in PHP)