Examveda
Examveda

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

A. 0

B. infinite loop

C. -1

D. 1

Answer: Option C

Solution(By Examveda Team)

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

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

Join The Discussion

Related Questions on Control Structures(Loop in PHP)