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

CSE :: PHP - CS

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

    <?php

    function sayHello()

    {

    echo "HelloWorld<br />";

    }

    $function_holder = "sayHello";

    $function_holder();

    ?>

  2. A.

     No Output

    B.

     Error

    C.

     sayHello

    D.

     HelloWorld


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

    span>

    function one()

    {

    echo " this works";

    function two()

    {

    echo "this too works";

    }

    }

    one();

    two();

    ?>

  4. A.

     error

    B.

     this works

    C.

     this worksthis too works

    D.

     this works this too works


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

    <?php

    function do($myString)

    {

    echo strpos($myString, "donkey",0);

    }

    do("The donkey looks like a horse.");

    ?>

  6. A.

     4

    B.

     5

    C.

     2

    D.

     None of the mentioned


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

    <?php

    function onespan>()

    {

    define("const","I am awesome!");

    echo constant("const");

    }

    one();

    ?>

  8. A.

     I am awesome!!

    B.

     const

    C.

     const, I am awesome!!

    D.

     “const”,”I am awesome!”


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

    <?php

    $title = "O'malley wins the heavyweight championship!";

    echo ucwords($title);

    ?>

  10. A.

     O’Malley Wins The Heavyweight Championship!

    B.

     O’malley Wins The Heavyweight Championship!

    C.

     O’Malley wins the heavyweight championship!

    D.

     o’malley wins the heavyweight championship!


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

    <?php

    echo str_pad("Salad", 5)." is good.";

    ?>

  12. A.

     SaladSaladSaladSaladSalad is good

    B.

     is good SaladSaladSaladSaladSalad

    C.

     is good Salad

    D.

     Salad is good


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

    <?php

    echo ucwords("i love my country");

    ?>

  14. A.

     I love my country

    B.

     i love my Country

    C.

     I love my Country

    D.

     I Love My Country


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

    <?php

    echo lcfirst("welcome to India");

    ?>

  16. A.

     welcome to India

    B.

     welcome to india

    C.

     Welcome to India

    D.

     Welcome to india


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

    <?php

    echo hex2bin("48656c6c6f20576f726c6421");

    ?>

  18. A.

     Hello World!

    B.

     welcome to india

    C.

     This is PHP!

    D.

     MCQ questons


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

    <?php

    $str = addslashes('What does "yolo" mean?');

    echo($str);

    ?>

  20. A.

     What does /”yolo/” mean?

    B.

     What does ”yolo” mean?

    C.

     What does ”yolo” mean?

    D.

     What does ”yolo” mean?