What will be the output of the following PHP code ?
<?php
$i = "";
while ($i)
{
print "hi";
}
while($i < 8)
$i++;
print "hello";
?>
<?php
$i = "";
while ($i)
{
print "hi";
}
while($i < 8)
$i++;
print "hello";
?>
A. Hi is printed 8 times, hello 7 times and then hi 2 times
B. Hi is printed 10 times, hello 7 times
C. Hi is printed once, hello 7 times
D. Hi is printed once, hello 7 times and then hi 2 times
Answer: Option D
Solution(By Examveda Team)
The while loop ends only when a } is encountered.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