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

CSE :: PHP - CS

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

    <?php

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

    {

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

    echo "$total";

    }

    calc(42);

    ?>

  2. A.

     Error

    B.

     0

    C.

     42

    D.

     84


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

  4. A.

     Only 2

    B.

     None of the mentioned

    C.

     All of the mentioned

    D.

     3 and 4


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

    ?>

  6. A.

     I am b

    B.

     I am bI am a

    C.

     Error

    D.

     I am a Error


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

    ?>

  8. A.

     I am b

    B.

     I am bI am a

    C.

     Error

    D.

     I am a Error


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

    <?php

    $op2 = "blabla";

    function foo($op1)

    {

    echo $op1;

    echo $op2;

    }

    foo("hello");

    ?>

  10. A.

     helloblabla

    B.

     Error

    C.

     hello

    D.

     helloblablablabla


  11. A function in PHP which starts with ______ (double underscore) is know as.

  12. A.

     Magic Function

    B.

     Inbuilt Function

    C.

     Default Function

    D.

     User Defined Function


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

    <?php

    function foo($msg)

    {

    echo "$msg";

    }

    $var1 = "foo";

    $var1("will this work");

    ?>

  14. A.

     Error

    B.

     $msg

    C.

     0

    D.

     Will this work


  15. Which one of the following PHP functions can be used to build a function that accepts any number of arguments?

  16. A.

     func_get_argv()

    B.

     func_get_argc()

    C.

     get_argv()

    D.

     get_argc()


  • Which one of the following PHP functions can be used to find files?

  • A.

     glob()

    B.

     file()

    C.

     fold()

    D.

     get_file()


  • Which of the following PHP functions can be used to get the current memory usage?

  • A.

     get_usage()

    B.

     get_peak_usage()

    C.

     get_memory_usage()

    D.

     get_memory_peak_usage()