Vidyalelo
PHP · all questions

Functions
practice.

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

81

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
function calc(tax="")
 {
    price + (tax);
    echo "$total"; 
 }
calc(42);    
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
    function a()
    {
        function b()
        {
            echo 'I am b';
        }
        echo 'I am a';
    }
    a();
    a();
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code?

<?php
    function a()
    {
        function b()
        {
            echo 'I am b';
        }
        echo 'I am a';
    }
    b();
    a();
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code?

<?php
$op2 = "blabla";
function foo($op1)
{
        echo $op1;
        echo $op2;
}
foo("hello");
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
function foo($msg)
{
    echo "$msg";
}
$var1 = "foo";
$var1("will this work");
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
   echo "chr(52)";
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
    echo ord ("hi");
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
   echo(atan(0.50));
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
   define("GREETING","Hello you! How are you today?");
   echo constant("GREETING");
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
define("GREETING1","Hello you! How are you today?");
define("GREETING2","Hello you! How are you today?");
define("GREETING3","Hello you! How are you today?");
echo defined("GREETING");
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
function sum(num2)
{
    num1 + $num2;
    echo "chr($total)"; 
}
$var1 = "sum";
$var1(5, 44);    
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
function sum(num2)
{
    num1 + $num2;
    echo "cos($total)"; 
}
sum(5,-5);    
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
function b()
{
    echo "b is executed";
}
function a()
{
    b();
    echo "a is executed";
    b();
}
a();
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
function addFunction(num2)
{
    num1 + $num2;
    return $sum;
}
$return_value = addFunction(10, 20);
echo "Returned value from the function : $return_value"
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
function sayHello()
{
   echo "HelloWorld<br />";
}
$function_holder = "sayHello";
$function_holder();
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code?
span>
function one()
{
    echo " this works";
    function two()
    {
        echo "this too works";
    }
}
one();
two();
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
function do($myString)
{
    echo strpos($myString, "donkey",0);
}
do("The donkey looks like a horse.");
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
function onespan>()
{
    define("const","I am awesome!");
    echo constant("const");
}
one();
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
    $title = "O'malley wins the heavyweight championship!";
    echo ucwords($title);
?>

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
    echo str_pad("Salad", 5)." is good.";
?>

Select an option to see the answer and solution.