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

4/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;
echo "$x";
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$x = 5;
{
    $x = 10;
    echo "$x";
}
echo "$x";
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$x = 5;
{
    echo "$x";
}
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$x = 5;
function fun()
{
    echo "$x";
}
fun();
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$x = 5;
function fun()
{
    $x = 10;
    echo "$x";
}
fun();
echo "$x";
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$x = 5;
function fun()
{
    $x = 10;
    echo "$x";
}
fun();
echo "$x";
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$x = 4;
$y = 3;
function fun(y = 4)
{
    x+y+$x;
    echo "$z";
} 
echo $x;
echo $y;
echo $z; 
fun(y);
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$x =4;
$y = 3;
function fun(y)
{
    x + y + $x;
    echo "$z";
}
echo $x;
echo $y;
echo $z; 
fun(3, 4);
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
function fun(y)
{
    $x = 4;
    $y = 3;
    x + y + $x;
    echo "$z";
}
fun(3, 4); 
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$x = 3, 4, 5, 6;
echo "$x";
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$a = 10;
$b = 4;
$c = fun(10,4);
function fun(b)
{
    $b = 3;
    return b + a; 
}
echo $a;
echo $b;
echo $c;
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
winner";
looser";
echo b;
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
winner";
looser";
echo b;
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
winner";
looser";
echo b;
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$x = 5;
$y = 10;
function fun()
{
    GLOBALS['x'] + $GLOBALS['y'];
} 
fun();
echo $y;
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
$x = 5;
$y = 10;
function fun()
{
    GLOBALS['x'] + $GLOBALS['y'];
} 
fun();
echo $y;
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code ?
<?php
function fun()
{
    $x = 0;
    echo $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
function fun()
{
    static $x = 0;
    echo $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
static $x = 0;
function fun()
{
    echo $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
$x=0;
function fun()
{
    echo $GLOBALS['x'];
    $GLOBALS['x']++;
}
fun();
fun();
fun();
?>

Select an option to see the answer and solution.