Vidyalelo
PHP · all questions

Control Structures(Loop In PHP)
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

86

Questions

3/5

Page

Pick an option on a question to see the right answer and solution.

What will be the output of the following PHP code ?
<?php
switch($b)
{
case 2:
    print "hello";
    break;
case 1:
    print "hi";
    break;
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
switch($b)
{
case 2:
    print "hello";
    break;
case b:
    print "hi";
    break;
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
while()
{
    print "hi";
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
do
{
    print "hi";
}
while(0);
print "hello";
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$i = 0
while ($i < 3)
{
    $i++;
}
print $i;
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$i = 0
do
{
    $i++;
}
while ($i < 3);
print $i;
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$i = 0
while ($i++)
{
    print $i;
}
print $i;
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$i = "";
while($i)
{   
    print "hi";
}
print "hello";
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$i = "";
while ($i)
{   
    print "hi";
} 
while($i < 8)
    $i++;
print "hello";
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$i = 0;
while($i = 10)
{   
    print "hi";
}
print "hello";
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$i = "";
while ($i = 10)
{   
    print "hi";
}
print "hello";
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$i = 5;
while (--$i > 0)
{   
    i; print "hello";
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$i = 5;
while (--i <span class="p-blue">><!--?span--> <span class="p-red">0</span> <span class="p-blue">&& ++</span>i)
{   
    print $i;
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$i = 5;
while (--i)
{   
    print $i;
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?phpspan>
$i = 0;
while(?++i)
{   
    print $i;
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$i = 0;
while (++i <span class="p-blue">&& --</span>i)
{   
    print $i;
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$i = 0;
while ((--i) - 1)
{   
    print $i;
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$i = 2;
while (++$i)
{   
    while ($i --> 0)
    print $i;
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$i = 2;
while (++$i)
{   
    while (--$i > 0)
    print $i;
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$i = 0;
for ($i)
{
    print $i;
}
?>

Select an option to see the answer and solution.