What will be the output of the following PHP code ?
<<php
for ($i == 2; ++$i == $i; ++$i)
print "In for loop ";
print "After loopn";
?>
<<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.Related Questions on Control Structures(Loop in PHP)
A. how are u
B. hi
C. error
D. no output
A. hi
B. no output
C. error
D. how are u
A. how are uhello
B. hihello
C. hi
D. no output
A. true
B. false
C. error
D. no output
Join The Discussion