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

CSE :: PHP - CS

  1. The arguments in a function are evaluated from .....

  2. A.

     left to right

    B.

     right to left

    C.

     sometimes left to right and sometimes right to left

    D.

     Always right to left


  3. strlen() returns the length of the string on success and . . . . if the string is empty.

  4. A.

     -1

    B.

     NULL

    C.

     Garbage value

    D.

     0


  5. Which one of the following is the right way of defining a function in PHP?

  6. A.

     function { function body }

    B.

     data type functionName(parameters) { function body }

    C.

     functionName(parameters) { function body }

    D.

     function fumctionName(parameters) { function body }


  7. Type Hinting was introduced in which version of PHP?

  8. A.

     PHP 4

    B.

     PHP 5

    C.

     PHP 5.3

    D.

     PHP 6


  9. What will happen in this function call?

    <?php

    function calc($price, $tax)

    {

    $total = $price + $tax;

    }

    $pricetag = 15;

    $taxtag = 3;

    calc($pricetag, $taxtag);

    ?>

  10. A.

     Call By Value

    B.

     Call By Reference

    C.

     Default Argument Value

    D.

     Type Hinting


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

    <?php

    function calc($price, $tax="")

    {

    $total = $price + ($price * $tax);

    echo "$total";

    }

    calc(42);

    ?>

  12. A.

     Error

    B.

     0

    C.

     42

    D.

     84


  13. Which of the following are valid function names? 1. function() 2. €() 3. .function() 4. $function()

  14. A.

     Only 2

    B.

     None of the mentioned

    C.

     All of the mentioned

    D.

     3 and 4


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

    ?>

  16. A.

     I am b

    B.

     I am bI am a

    C.

     Error

    D.

     I am a Error


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

    ?>

  18. A.

     I am b

    B.

     I am bI am a

    C.

     Error

    D.

     I am a Error


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

    <?php

    $op2 = "blabla";

    function foo($op1)

    {

    echo $op1;

    echo $op2;

    }

    foo("hello");

    ?>

  20. A.

     helloblabla

    B.

     Error

    C.

     hello

    D.

     helloblablablabla