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

CSE :: PHP - CS

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

    <?php

    $color = "red";

    $color = "green";

    echo "$color";

    ?>

  2. A.

     red

    B.

     green

    C.

     red green

    D.

     error


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

    <?php

    $color1 = "red";

    $color2 = "green";

    echo "$color1" . "$color2";

    ?>

  4. A.

     red

    B.

     green

    C.

     red green

    D.

     redgreen


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

    <?php

    $color1 = "red";

    $color2 = "green";

    echo "$color1" + "$color2";

    ?>

  6. A.

     redgreen

    B.

     red green

    C.

     0

    D.

     error


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

    <?php

    $color1 = "red";

    $color2 = "red";

    echo "$color1" + "$color2";

    ?>

  8. A.

     redgreen

    B.

     red green

    C.

     0

    D.

     1


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

    <?php

    $color1 = "red";

    $color2 = "1";

    echo "$color1" + "$color2";

    ?>

  10. A.

     red1

    B.

     red 1

    C.

     0

    D.

     1


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

    <?php

    $color1 = "1";

    $color2 = "1";

    echo "$color1" + "$color2";

    ?>

  12. A.

     11

    B.

     2

    C.

     0

    D.

     1


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

    <?php

    $color1 = "red";

    $color2 = "1";

    $color3 = "grey"

    echo "$color1" + "$color2" . "$color3";

    ?>

  14. A.

     1grey

    B.

     grey

    C.

     0

    D.

     red1grey


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

    <?php

    echo "This", "was", "a", "bad", "idea";

    ?>

  16. A.

     This, was, a, bad, idea

    B.

     This was a bad idea

    C.

     Thiswasabadidea

    D.

     Error


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

    <?php

    echo "This"."was"."a"."bad"."idea";

    ?>

  18. A.

     This, was, a, bad, idea

    B.

     This was a bad idea

    C.

     Thiswasabadidea

    D.

     Error


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

    <?php

    echo "This","was"|"a","bad"."idea";

    ?>

  20. A.

     Thiswasabadidea

    B.

     Thiswasbadidea

    C.

     Thiswas a badidea

    D.

     Thiswas abadidea