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

4/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
for (x <= 10; print ++$x)
{
    print ++$x;
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
for (x < 10;++$x)
{
    print "*t";
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
for (x < 10;--$x)
{
    print $x;
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$x;
for (x < -5; ++$x)
{
    print ++$x;
}
?>

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
for (x < 10; $x++)
    for (y < 5; $y++)
        print "Hello";
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
for (count != 20;$count++)
{
    print $count;
    $count++;
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
for (count < 20; $count++);
    print $count;
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
for (count < 3;$count++);
{
    print "hi";continue;print "hello";
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
for (count<3;$count++);
{
    print "hi";break;print "hello";
}
?>

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$user = array("Ashley", "Bale", "Shrek", "Blank");
for (x < count(x++) 
{
    if (x] == "Shrek") 
	    continue;
    printf (x]); 
}
?>

Select an option to see the answer and solution.