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

CSE :: PHP - CS

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

    <?php

    function _func()

    {

    echo "Hello World";

    }

    _func();

    ?>

  2. A.

     Hello World

    B.

     No Output

    C.

     ERROR

    D.

     None of the mentioned


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

    <?php

    function test($int)

    {

    if ($int == 1)

    echo "This Works";

    if ($int == 2)

    echo "This Too Seems To Work";

    }

    test(1);

    TEST(2);

    ?>

  4. A.

     This Works

    B.

     This Too Seems To Work

    C.

     This WorksThis Too Seems To Work

    D.

     ERROR


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

    <?php

    function mine($num)

    {

    $num = 2 + $num;

    echo $num;

    }

    mine(3);

    ?>

  6. A.

     3

    B.

     $num

    C.

     5

    D.

     None of the mentioned


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

    <?php

    function mine($num)

    {

    $num = 2 + $num;

    echo "$num";

    }

    mine(3);

    ?>

  8. A.

     3

    B.

     $num

    C.

     5

    D.

     None of the mentioned


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

    <?php

    function movie($int)

    {

    $movies = array("Fight Club", "Kill Bill", "Pulp Fiction");

    echo "You Do Not Talk About ". $movie[$integer];

    }

    movie(0);

    ?>

  10. A.

     I

    B.

     You Do Not Talk About Fight Club

    C.

     You Do Not Talk About Kill Bill

    D.

     You Do Not Talk About Pulp Fiction

    E.

     None of the mentioned


  11. 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

    ?>

  12. A.

     Returned value from the function : $return_value

    B.

     Error

    C.

     Returned value from the function : 30

    D.

     Returned value from the function :


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

    <?php

    function time($string)

    {

    echo strtr("Towe Pa55", "ow5", $string);

    }

    time("ims");

    ?>

  14. A.

     Time Pa55

    B.

     Towe Pa55

    C.

     Towe Pass

    D.

     Time Pass


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

    <?php

    function constant()

    {

    define("GREETING", "Welcome to Narnia");

    echo greeting;

    }

    ?>

  16. A.

     Welcome to Narnia

    B.

     greeting

    C.

     GREETING

    D.

     ERROR


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

    <?php

    function constant()

    {

    define("GREETING", "Welcome to Narnia",true);

    echo greeting;

    }

    ?>

  18. A.

     Welcome to Narnia

    B.

     greeting

    C.

     GREETING

    D.

     ERROR


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

    <?php

    function start($string)

    {

    if ($string < 45)

    return 20;

    else

    return 40;

    }

    $t = start(90);

    if ($t < 20)

    {

    echo "Have a good day!";

    }

    else

    {

    echo "Have a good night!";

    }

    ?>

  20. A.

     Have a good day!

    B.

     Have a good night!

    C.

     ERROR

    D.

     None of the mentioned