Vidyalelo
PHP · all questions

Operators And Expressions
practice.

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

143

Questions

5/8

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 = 0;
function fun()
{
    echo $GLOBALS['x'];
    $x++;
}
fun();
fun();
fun();
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$a = 10;
echo ++$a;
echo $a++;
echo $a;
echo ++$a;
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$a = 12;
--$a;
echo $a++;
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$x = "test";
$y = "this";
$z = "also"; 
y .= $z ;
echo $x;
echo $y;
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$x = 1;
$y = 2;
if (++y++)
{
    echo "true ", x;
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$y = 2;
$w = 4;
w /= $y;
echo w;
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$y = 2;
if (y)
{
    echo $y;
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$y = 2;
if (**$y == 4)
{
    echo $y;
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$y = 2;
if (--y xor --$y)
{
    echo $y;
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$y = 2;
if (--y != $y++))
{
    echo $y;
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?

<?php
echo x;
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$auth = 1;
$status = 1;
if (auth == 1) && ($status != 0)))
{
    print "result is $result";
}
?>

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 $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 ?
<?php
$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.