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

CSE :: PHP - CS

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

    <?php

    define("GREETING","Hello you! How are you today?");

    echo constant("GREETING");

    ?>

  2. A.

     Hello you! How are you today?

    B.

     GREETING

    C.

     GREETING, Hello you! How are you today?

    D.

     “GREETING”,”Hello you! How are you today?”

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    <?php

    function sum($num1, $num2)

    {

    $total = $num1 + $num2;

    echo "chr($total)";

    }

    $var1 = "sum";

    $var1(5, 44);

    ?>

  4. A.

     Error

    B.

     49

    C.

     1

    D.

     Sum

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    <?php

    function sum($num1, $num2)

    {

    $total = $num1 + $num2;

    echo "cos($total)";

    }

    sum(5,-5);

    ?>

  6. A.

     0

    B.

     1

    C.

     0.5

    D.

     -0.5

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    <?php

    function b()

    {

    echo "b is executed";

    }

    function a()

    {

    b();

    echo "a is executed";

    b();

    }

    a();

    ?>

  8. A.

     b is executedb is executedb is executed

    B.

     b is executeda is executed

    C.

     a is executed

    D.

     b is executeda is executedb is executed

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    ?>

  10. A.

     Returned value from the function : $return_value

    B.

     Error

    C.

     Returned value from the function : 30

    D.

     Returned value from the function :

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    <?php

    function sayHello()

    {

    echo "HelloWorld<br />";

    }

    $function_holder = "sayHello";

    $function_holder();

    ?>

  12. A.

     No Output

    B.

     Error

    C.

     sayHello

    D.

     HelloWorld

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    span>

    function one()

    {

    echo " this works";

    function two()

    {

    echo "this too works";

    }

    }

    one();

    two();

    ?>

  14. A.

     error

    B.

     this works

    C.

     this worksthis too works

    D.

     this works this too works

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. 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.");

    ?>

  16. A.

     4

    B.

     5

    C.

     2

    D.

     None of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    <?php

    function onespan>()

    {

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

    echo constant("const");

    }

    one();

    ?>

  18. A.

     I am awesome!!

    B.

     const

    C.

     const, I am awesome!!

    D.

     “const”,”I am awesome!”

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    <?php

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

    echo ucwords($title);

    ?>

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

    View Answer

    Workspace

    Discuss Discuss in Forum