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

2/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
$x = 1;
if (x& 0)
    print $x ;
else
    print "how are u";
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$x = 1;
if (x& 0)
    print $x;
else
    break;
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$x = 10;
$y = 5;
$z = 3;
if (y / $z)
    print "hi";
else
    print "hello";
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
if (!print "hi")
    if (print "hello")
print "hi";
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
if (print "hi" - 1)
    print "hello"
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$x = 1;
if ($x--)
    print "hi"
    $x--;
else
    print "hello"
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$a = 10;
$b = 11;
if (a || b)
    print "hello";
else
    print "hi";
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$a = 2;
if (a - $a)
    print "hello";
else
    print "hi";
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$a = 2;
if (a - $a)
    print "hello";
else
    print "hi";
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$a = "hello";
if ($a.length)
    print $a.length;
else
    print "hi";
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$a = "hello";
if (strlen($a))
    print strlen($a);
else
    print "hi";
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$a = "1";
$b = "0";
if ((int)a <span class="p-blue">&&</span>b) 
    print"hi";
else 
    print "hello";
?>

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$a = 97;
switch(?$a)
{
case "a":
    print "hi";
    break;
case 97:
    print "hello";
    break;
default:
    print "hi1";
}
?>

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.