PHP Loop MCQs
11. What will be the output of the following PHP code ?
<?php
do
{
print "LFC";
}
while(10);
print "I LOVE WEBSITE";
?>
View Answer
12. What will be the output of the following PHP code ?
<?php
$a;
for ($a = -3; $a < -5; ++$a)
{
print $x++;
}
?>
View Answer
13. What will be the output of the following PHP code ?
<?php
for ($a = 1; $a <= 10; $a++){
for ($b = 1; $b <= 5; $b++){
print "LFC
";
}
}
?>
View Answer
14. What will be the output of the following PHP code ?
<?php
for($num = 10; $num<=20; print ++$num)
{
print ++$num;
}
?>
View Answer
15. What will be the output of the following PHP code ?
<?php
$i=-5;
while($i){
$i++;
if($i%2==0)
continue;
else
{
$i++;
}
echo($i);
}
?>
View Answer
16. What will be the output of the following PHP code ?
<?php
for ($i = 0; $i < 4; $i++)
{
for ($j = 0; $j < 3; $j++)
{
if ($i > 1)
continue;
echo("Hi
");
}
}
?>
View Answer
17. What will be the output of the following PHP code ?
<?php
$i = 0;
$j = 0;
first: while ($i < 2)
{
$i++;
while ($j < 3)
{
$j++;
echo("loop
");
if($j%2==0)
continue;
goto first;
}
}
?>
View Answer
18. What will be the output of the following PHP code ?
<?php
for($i=0; $i<=5; $i++){
$i = $i+1;
}
echo "$i";
?>
View Answer
19. What will be the output of the following PHP code ?
<?php
$a = 10;
$b = $a>2?"Hi":"Bye";
echo "$b";
?>
View Answer
20. What will be the output of the following PHP code ?
<?php
$a = 0;
if($a > 1 );
{
echo "Sun";
}
echo "Moon";
?>
View Answer