adplus-dvertising

Welcome to the Functions in PHP MCQs Page

Dive deep into the fascinating world of Functions in PHP with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Functions in PHP, a crucial aspect of PHP. In this section, you will encounter a diverse range of MCQs that cover various aspects of Functions in PHP, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within PHP.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Functions in PHP. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of PHP.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Functions in PHP. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Functions in PHP MCQs | Page 2 of 6

Explore more Topics under PHP

Q11.
What will be the output of the following PHP code?
<?php
    function sum($num1, $num2)
    {
        $total = $num1 + $num2;
        echo "cos($total)"; 
    }
    sum(5,-5);    
?>
Discuss
Answer: (b).1
Q12.
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();
  ?>
Discuss
Answer: (d).b is executeda is executedb is executed
Q13.
What will be the output of the following PHP code?
<?php
function sum($x, $y)
{
    $z = $x + $y;
    return $z;
}
echo "5 + 10 = " . sum(7,13) . "<br>";
echo "7 + 13 = " . sum(2,4) . "<br>";
echo "2 + 4 = " . sum(5,10);
?>
Discuss
Answer: (d).5 + 10 = 20
7 + 13 = 6
2 + 4 = 15
Q14.
What will be the output of the following PHP code?
<?php
function addFive($num)
{
    $num += 5;
}
function addSix(&$num)
{
    $num += 6;
}
$orignum = 10;
addFive( &$orignum );
echo "Original Value is $orignum<br />";
addSix( $orignum );
echo "Original Value is $orignum<br />";
?>
Discuss
Answer: (b).Original Value is 15
Original Value is 21
Q15.
What will be the output of the following PHP code?
<?php
function addFunction($num1, $num2)
{
    $sum = $num1 + $num2;
    return $sum;
}
$return_value = addFunction(10, 20);
echo "Returned value from the function : $return_value"
?>
Discuss
Answer: (c).Returned value from the function : 30
Q16.
What will be the output of the following PHP code?
<?php
function sayHello()
{
   echo "HelloWorld<br />";
}
$function_holder = "sayHello";
$function_holder();
?>
Discuss
Answer: (d).HelloWorld
Q17.
What will be the output of the following PHP code?
<?php
function one()
{
    echo " this works";
    function two()
    {
        echo "this too works";
    }
}
one();
two();
?>
Discuss
Answer: (c).this worksthis too works
Q18.
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.");
?>
Discuss
Answer: (a).4
Q19.
What will be the output of the following PHP code?
<?php
function one()
{
    define("const","I am awesome!");
    echo constant("const");
}
one();
?>
Discuss
Answer: (a).I am awesome!!
Q20.
What will be the output of the following PHP code?
<?php
    $title = "O'malley wins the heavyweight championship!";
    echo ucwords($title);
?>
Discuss
Answer: (d).o’malley wins the heavyweight championship!
Page 2 of 6

Suggested Topics

Are you eager to expand your knowledge beyond PHP? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!