Home / CSE / PHP - CS :: Functions in PHP

CSE :: PHP - CS

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

    <?php

    $op2 = "blabla";

    function foo($op1)

    {

    echo $op1;

    echo $op2;

    }

    foo("hello");

    ?>

  2. A.

     helloblabla

    B.

     error

    C.

     hello

    D.

     helloblablablabla


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

    <?php

    function foo($msg)

    {

    echo "$msg";

    }

    $var1 = "foo";

    $var1("will this work");

    ?>

  4. A.

     error

    B.

     $msg

    C.

     0

    D.

     will this work


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

    <?php

    echo "chr(52)";

    ?>

  6. A.

     1

    B.

     2

    C.

     3

    D.

     4


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

    <?php

    echo ord ("hi");

    ?>

  8. A.

     106

    B.

     103

    C.

     104

    D.

     209


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

    <?php

    echo(atan(0.50));

    ?>

  10. A.

     0.11845976421345

    B.

     0.23568451142521

    C.

     0.46364760900081

    D.

     1


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

    <?php

    define("GREETING","Hello you! How are you today?");

    echo constant("GREETING");

    ?>

  12. 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?”


  13. 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);

    ?>

  14. A.

     Error

    B.

     49

    C.

     1

    D.

     Sum


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

    <?php

    function sum($num1, $num2)

    {

    $total = $num1 + $num2;

    echo "cos($total)";

    }

    sum(5,-5);

    ?>

  16. A.

     0

    B.

     1

    C.

     0.5

    D.

     -0.5


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

    ?>

  18. A.

     b is executedb is executedb is executed

    B.

     b is executeda is executed

    C.

     a is executed

    D.

     b is executeda is executedb is executed


  19. 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"

    ?>

  20. A.

     Returned value from the function : $return_value

    B.

     Error

    C.

     Returned value from the function : 30

    D.

     Returned value from the function :