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

CSE :: PHP - CS

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

    ?>

  2. A.

     Returned value from the function : $return_value

    B.

     Error

    C.

     Returned value from the function : 30

    D.

     Returned value from the function :


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

    <?php

    function time($string)

    {

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

    }

    time("ims");

    ?>

  4. A.

     Time Pa55

    B.

     Towe Pa55

    C.

     Towe Pass

    D.

     Time Pass


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

    <?php

    function constant()

    {

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

    echo greeting;

    }

    ?>

  6. A.

     Welcome to Narnia

    B.

     greeting

    C.

     GREETING

    D.

     ERROR


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

    <?php

    function constant()

    {

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

    echo greeting;

    }

    ?>

  8. A.

     Welcome to Narnia

    B.

     greeting

    C.

     GREETING

    D.

     ERROR


  9. 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!";

    }

    ?>

  10. A.

     Have a good day!

    B.

     Have a good night!

    C.

     ERROR

    D.

     None of the mentioned


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

    <?php

    function email()

    {

    $email = ’contact@examveda.com’;

    $new = strstr($email, ‘@');

    echo $new;

    }

    email();

    ?>

  12. A.

     contact

    B.

     contact@examveda.com

    C.

     @examveda.com

    D.

     examveda.com


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

    <?php

    function string()

    {

    echo strstr("Hello world!", 111);

    }

    string();

    ?>

  14. A.

     o world!

    B.

     Hello world!

    C.

     111

    D.

     No Output


  15.  . . . . . converts the keys of an array into values and the values into keys.

  16. A.

     array_flips()

    B.

     array_transpose()

    C.

     array_trans()

    D.

     array_flip()


  17. Above usleep() function pauses PHP for .

    usleep(1000000);

  18. A.

     1 second

    B.

     1 microseconds

    C.

     10 seconds

    D.

     100 microseconds


  19. Output will be:

    $array = array(0, 1, 2);

    $array = array_pad($array, -6, ‘NEW’);

  20. A.

     Array ( [1] => NEW [2] => NEW [3] => NEW [4] => 0 [5] => 1 [6] => 2 )

    B.

     Array ( [-1] => NEW [-2] => NEW [-3] => NEW [-4] => 0 [-5] => 1 [-6] => 2 )

    C.

     Array ( [0] => NEW [-1] => NEW [-2] => NEW [-3] => 0 [-4] => 1 [-5] => 2 )

    D.

     Array ( [0] => NEW [1] => NEW [2] => NEW [3] => 0 [4] => 1 [5] => 2 )