Examveda
Examveda

What will be the output of the following PHP code ?
<<php
for ($i == 2; ++$i == $i; ++$i)
    print "In for loop ";
    print "After loopn";
?>

A. In for loopIn for loopIn for loopIn for loop……infinitely

B. After for loopAfter for loopAfter for loop……..infinitely

C. In for loopAfter for loopIn for loopAfter for loopIn for loopAfter for loop…..infinitely

D. After for loop

Answer: Option A

Solution(By Examveda Team)

The loop never exits as the condition ++X == X is always satisfied,evaluated from right to left.

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

Join The Discussion

Related Questions on Control Structures(Loop in PHP)