Home / CSE / PHP - CS :: Operators and Expressions in php

CSE :: PHP - CS

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

    <?php

    $x = 0;

    function fun()

    {

    echo $GLOBALS['x'];

    $x++;

    }

    fun();

    fun();

    fun();

    ?>

  2. A.

     000

    B.

     012

    C.

     Nothing

    D.

     Error


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

    <?php

    $a = 10;

    echo ++$a;

    echo $a++;

    echo $a;

    echo ++$a;

    ?>

  4. A.

     11111213

    B.

     11121213

    C.

     11111212

    D.

     11111112


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

    <?php

    $a = 12;

    --$a;

    echo $a++;

    ?>

  6. A.

     11

    B.

     12

    C.

     10

    D.

     error


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

    <?php

    $x = "test";

    $y = "this";

    $z = "also";

    $x .= $y .= $z ;

    echo $x;

    echo $y;

    ?>

  8. A.

     testthisthisalso

    B.

     testthis

    C.

     testthisalsothisalso

    D.

     error at line 4


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

    <?php

    $x = 1;

    $y = 2;

    if (++$x == $y++)

    {

    echo "true ", $y, $x;

    }

    ?>

  10. A.

     no output

    B.

     true 23

    C.

     true 22

    D.

     true 33


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

    <?php

    $y = 2;

    $w = 4;

    $y *= $w /= $y;

    echo $y, $w;

    ?>

  12. A.

     80.5

    B.

     44

    C.

     82

    D.

     42


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

    <?php

    $y = 2;

    if ($y-- == ++$y)

    {

    echo $y;

    }

    ?>

  14. A.

     2

    B.

     1

    C.

     3

    D.

     no output


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

    <?php

    $y = 2;

    if (**$y == 4)

    {

    echo $y;

    }

    ?>

  16. A.

     4

    B.

     2

    C.

     error at line2

    D.

     no output


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

    <?php

    $y = 2;

    if (--$y == 2 || $y xor --$y)

    {

    echo $y;

    }

    ?>

  18. A.

     1

    B.

     0

    C.

     2

    D.

     no output


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

    <?php

    $y = 2;

    if (--$y <> ($y != $y++))

    {

    echo $y;

    }

    ?>

  20. A.

     1

    B.

     0

    C.

     2

    D.

     no output