My Report

PHP Function Test – 1


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. What will be the output of the following PHP code?

    <?php
        function foo($msg)
        {
            echo "$msg";
        }
        $var1 = "foo";
        $var1("will this work");
    ?>

2. What will be the output of the following PHP code?

    <?php
    function calc($price, $tax="")
    {
        $total = $price + ($price * $tax);
        echo "$total"; 
    }
    calc(42);    
    ?>

3. 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();
    ?>

4. What will be the output of the following PHP code?

    <?php
       echo "chr(52)";
    ?>

5. What will be the output of the following PHP code?

    <?php
        echo ord ("hi");
    ?>

6. What will be the output of the following PHP code?

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

7. 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");
     ?>

8. 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();
    ?>

9. What will be the output of the following PHP code?

  <?php
      echo(atan(0.50));
  ?>

10. What will be the output of the following PHP code?

   <?php
       define("GREETING","Hello you! How are you today?");
       echo constant("GREETING");
   ?>

 

Start practicing “1000 MCQs on PHP”, and once you are ready, you can take tests on all topics by attempting our “PHP Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.