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

CSE :: PHP - CS

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

    <?php

    function calc($num1, $num2)

    {

    $total = $num1 * $num2;

    return $total;

    }

    $result = calc(42, 0);

    echo $result;

    ?>

  2. A.

     Error

    B.

     0

    C.

     42

    D.

     84


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

    <?php

    $var = 10;

    function one()

    {

    echo $var;

    }

    one();

    ?>

  4. A.

     Error

    B.

     10

    C.

     No Output

    D.

     None of the Mentioned


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

    <?php

    function mine($m)

    {

    if ($m < 0)

    echo "less than 0";

    if ($ >= 0)

    echo "Not True";

    }

    mine(0);

    ?>

  6. A.

     Less Than 0

    B.

     Not True

    C.

     No Output

    D.

     None of the Mentioned


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

    <?php

    $x = 75;

    $y = 25;

    function addition()

    {

    $GLOBALS['z'] = $GLOBALS['x'] + $GLOBALS['y'];

    }

    addition();

    echo $z;

    ?>

  8. A.

     100

    B.

     error

    C.

     75

    D.

     25


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

    <?php

    function 2myfunc()

    {

    echo "Hello World";

    }

    2myfunc();

    ?>

  10. A.

     Hello World

    B.

     No Output

    C.

     ERROR

    D.

     None of the mentioned


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

    <?php

    function _func()

    {

    echo "Hello World";

    }

    _func();

    ?>

  12. A.

     Hello World

    B.

     No Output

    C.

     ERROR

    D.

     None of the mentioned


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

    ?>

  14. A.

     This Works

    B.

     This Too Seems To Work

    C.

     This WorksThis Too Seems To Work

    D.

     ERROR


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

    <?php

    function mine($num)

    {

    $num = 2 + $num;

    echo $num;

    }

    mine(3);

    ?>

  16. A.

     3

    B.

     $num

    C.

     5

    D.

     None of the mentioned


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

    <?php

    function mine($num)

    {

    $num = 2 + $num;

    echo "$num";

    }

    mine(3);

    ?>

  18. A.

     3

    B.

     $num

    C.

     5

    D.

     None of the mentioned


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

    ?>

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