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

CSE :: PHP - CS

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

    <?php

    class myObject { }

    define('myObject::CONSTANT', 'test');

    echo myObject::CONSTANT;

    ?>

  2. A.

     test

    B.

     error

    C.

     myObject::CONSTANT

    D.

     no output


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

    <?php

    $x = 5;

    $y = 10;

    $z = "$x + $y";

    echo "$z";

    ?>

  4. A.

     15

    B.

     10 + 5

    C.

     $z

    D.

     $x + $y


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

    <?php

    $x = 4;

    $y = 3;

    $z = 1;

    echo "$x = $x + $y + $z";

    ?>

  6. A.

     4 = 4 + 3 + 1

    B.

     8

    C.

     8 = 4 + 3 +1

    D.

     Error


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

    <?php

    $x = 4;

    $y = 3

    $z = 1;

    $z = $z + $x + $y;

    echo "$z";

    ?>

  8. A.

     $z

    B.

     15

    C.

     8

    D.

     1


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

    <?php

    $x = 3.3;

    $y = 2;

    echo $x % $y;

    ?>

  10. A.

     0

    B.

     1

    C.

     2

    D.

     Error


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

    <?php

    $x = 10;

    $y = 4;

    $z = 3;

    echo $x % $y % $z;

    ?>

  12. A.

     0

    B.

     1

    C.

     2

    D.

     Error


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

    <?php

    $x = 10;

    $y = 4;

    $z = 3;

    echo ($x % ($y) + $z);

    ?>

  14. A.

     5

    B.

     3

    C.

     0

    D.

     1


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

    <?php

    $x = 30;

    $y = 20;

    $z = 10;

    echo $x + $y - $z / ($z - $y);

    ?>

  16. A.

     41

    B.

     -4

    C.

     -5

    D.

     51


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

    <?php

    $x = 4;

    $y = -3;

    $z = 11;

    echo 4 + $y * $z / $x;

    ?>

  18. A.

     4.25

    B.

     3.25

    C.

     -3.25

    D.

     -4.25


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

    <?php

    $x = 3.5;

    $y = 2;

    $z = 2;

    echo $x / $y / $z;

    ?>

  20. A.

     1.75

    B.

     0.875

    C.

     3.5

    D.

     Error