Home / CSE / Functions in PHP :: Functions in PHP

CSE :: Functions in PHP

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

  2. A.

     function { function body }

    B.

     data type functionName(parameters) { function body }

    C.

     functionName(parameters) { function body }

    D.

     function fumctionName(parameters) { function body }

    View Answer

    Workspace

    Discuss Discuss in Forum


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

  4. A.

     PHP 4

    B.

     PHP 5

    C.

     PHP 5.3

    D.

     PHP 6

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What will happen in this function call?

    <?php

    function calc($price, $tax)

    {

    $total = $price + $tax;

    }

    $pricetag = 15;

    $taxtag = 3;

    calc($pricetag, $taxtag);

    ?>

  6. A.

     Call By Value

    B.

     Call By Reference

    C.

     Default Argument Value

    D.

     Type Hinting

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    <?php

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

    {

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

    echo "$total";

    }

    calc(42);

    ?>

  8. A.

     Error

    B.

     0

    C.

     42

    D.

     84

    View Answer

    Workspace

    Discuss Discuss in Forum


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

  10. A.

     Only 2

    B.

     None of the mentioned

    C.

     All of the mentioned

    D.

     3 and 4

    View Answer

    Workspace

    Discuss Discuss in Forum