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

What will be the output of the following PHP code?
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: c
Explanation: The order of execution is initialization, check, increment/decrement, check, increment/decrement, check, increment/decrement….so on.
 

Tìm kiếm

Back
Top