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

CSE :: PHP - CS

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

  2. 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 one of the following is the right way of defining a function in PHP?

  • A.

     function { function body }

    B.

     data type functionName(parameters) { function body }

    C.

     functionName(parameters) { function body }

    D.

     function fumctionName(parameters) { function body }


  • Type Hinting was introduced in which version of PHP?

  • A.

     PHP 4

    B.

     PHP 5

    C.

     PHP 5.3

    D.

     PHP 6


  • What will happen in this function call?

    <?php

    function calc($price, $tax)

    {

    $total = $price + $tax;

    }

    $pricetag = 15;

    $taxtag = 3;

    calc($pricetag, $taxtag);

    ?>

  • A.

     Call By Value

    B.

     Call By Reference

    C.

     Default Argument Value

    D.

     Type Hinting


  • 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


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

  • A.

     Only 2

    B.

     None of the mentioned

    C.

     All of the mentioned

    D.

     3 and 4


  • 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


  • 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


  • What will be the output of the following PHP code?

    <?php

    $op2 = "blabla";

    function foo($op1)

    {

    echo $op1;

    echo $op2;

    }

    foo("hello");

    ?>

  • A.

     helloblabla

    B.

     Error

    C.

     hello

    D.

     helloblablablabla