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

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$a = 1;
if ($a--)
    print "True";
if ($a++)
    print "False"; 
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$a = 1;
if (echo $a)
    print "True";
else
    print "False"; 
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$a = 1;
if (print $a)
    print "True";
else
    print "False"; 
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$a = 10;
if (1) 
    print "all";
else 
    print "some"
else 
    print "none";
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$a = 10;
if (0) 
    print "all";
 if 
 else 
     print "some"
?>

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$x = 10;
$y = 20;
if (y + $y != 3)
    print "hi" ;
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 = 10;
$y = 20;
if (y && 1||1)
    print "hi" ;
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 = 10;
$y = 20;
if (y && 1||1)
    print "hi" ;
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
if (-100)
    print "hi" ;
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
if (0.1)
    print "hi" ;
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
if (0.0)
    print "hi" ;
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
if (print "0")
    print "hi" ;
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 == 2)
    print "hi" ;
else if($x = 2)
    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
    print "how are u";
?>

Select an option to see the answer and solution.