adplus-dvertising
1. What will be the output of the following PHP code?
<?php
    function calc($price, $tax="")
    {
        $total = $price + ($price * $tax);
        echo "$total"; 
    }
    calc(42);    
    ?>
a. Error
b. 0
c. 42
d. 84
Answer: (c).42

2. 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();
    ?>
a. I am b
b. I am bI am a
c. Error
d. I am a Error
Answer: (d).I am a Error

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();
    ?>
a. I am b
b. I am bI am a
c. Error
d. I am a Error
Answer: (c).Error

4. 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");
    ?>
a. error
b. $msg
c. 0
d. will this work
Answer: (d).will this work

5. What will be the output of the following PHP code?
<?php
       echo "chr(52)";
    ?>
a. 1
b. 2
c. 3
d. 4
Answer: (d).4

6. What will be the output of the following PHP code?
<?php
        echo ord ("hi");
    ?>
a. 106
b. 103
c. 104
d. 209
Answer: (c).104

7. What will be the output of the following PHP code?
<?php
      echo(atan(0.50));
  ?>
a. 0.11845976421345
b. 0.23568451142521
c. 0.46364760900081
d. 1
Answer: (c).0.46364760900081

8. What will be the output of the following PHP code?
<?php
       define("GREETING","Hello you! How are you today?");
       echo constant("GREETING");
   ?>
a. Hello you! How are you today?
b. GREETING
c. GREETING, Hello you! How are you today?
d. “GREETING”,”Hello you! How are you today?”
Answer: (a).Hello you! How are you today?

9. 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
Answer: (b).0

10. 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);    
?>
a. Error
b. 49
c. 1
d. Sum
Answer: (c).1

Page 1 of 6