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 1 of 6

Q1.
What will be the output of the following PHP code?
<?php
    function calc($price, $tax="")
    {
        $total = $price + ($price * $tax);
        echo "$total"; 
    }
    calc(42);    
    ?>
Discuss
Answer: (c).42
Q2.
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();
    ?>
Discuss
Answer: (d).I am a Error
Q3.
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();
    ?>
Discuss
Answer: (c).Error
Q4.
hat will be the output of the following PHP code?
<?php
    $op2 = "blabla";
    function foo($op1)
    {
        echo $op1;
        echo $op2;
    }
    foo("hello");
    ?><?php
        function foo($msg)
        {
            echo "$msg";
        }
        $var1 = "foo";
        $var1("will this work");
    ?>
Discuss
Answer: (d).will this work
Q5.
What will be the output of the following PHP code?
<?php
       echo "chr(52)";
    ?>

a.

1

b.

2

c.

3

d.

4

Discuss
Answer: (d).4
Q6.
What will be the output of the following PHP code?
<?php
        echo ord ("hi");
    ?>
Discuss
Answer: (c).104
Q7.
What will be the output of the following PHP code?
<?php
      echo(atan(0.50));
  ?>
Discuss
Answer: (c).0.46364760900081
Q8.
What will be the output of the following PHP code?
<?php
       define("GREETING","Hello you! How are you today?");
       echo constant("GREETING");
   ?>
Discuss
Answer: (a).Hello you! How are you today?
Q9.
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");
     ?>

a.

1

b.

0

c.

3

d.

4

Discuss
Answer: (b).0
Q10.
What will be the output of the following PHP code?
<?php
    function sum($num1, $num2)
    {
        $total = $num1 + $num2;
        echo "chr($total)"; 
    }
    $var1 = "sum";
    $var1(5, 44);    
?>
Discuss
Answer: (c).1
Page 1 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!