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

CSE :: PHP - CS

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

    <?php

    $i = 2;

    while (++$i)

    {

    while ($i --> 0)

    print $i;

    }

    ?>

  2. A.

     210

    B.

     10

    C.

     no output

    D.

     infinite loop

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    <?php

    $i = 2;

    while (++$i)

    {

    while (--$i > 0)

    print $i;

    }

    ?>

  4. A.

     210

    B.

     10

    C.

     no output

    D.

     infinite loop

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    <?php

    echo 5 * 9 / 3 + 9;

    ?>

  6. A.

     24

    B.

     3.7

    C.

     3.85

    D.

     0

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    <?php

    $i = 0;

    $j = 0;

    if ($i && ($j = $i + 10))

    {

    echo "true";

    }

    echo $j;

    ?>

  8. A.

     10

    B.

     0

    C.

     true0

    D.

     true10

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    <?php

    $i = 10;

    $j = 0;

    if ($i || ($j = $i + 10))

    {

    echo "true";

    }

    echo $j;

    ?>

  10. A.

     20

    B.

     true0

    C.

     0

    D.

     true20

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    <?php

    $i = 1;

    if ($i++ && ($i == 1))

    printf("Yesn$i");

    else

    printf("Non$i");

    ?>

  12. A.

     No 2

    B.

     Yes 1

    C.

     Yes 2

    D.

     No 1

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    <?php

    $a = 1; $b = 3;

    $d = $a++ + ++$b;

    echo $d;

    ?>

  14. A.

     5

    B.

     4

    C.

     3

    D.

     error

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    <?php

    $a = 1; $b = 1; $d = 1;

    print ++$a + ++$a+$a++; print $a++ + ++$b; print ++$d + $d++ + $a++;

    ?>

  16. A.

     869

    B.

     742

    C.

     368

    D.

     error

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    <?php

    $a = 10; $b = 10;

    if ($a = 5)

    $b--;

    print $a;print $b--;

    ?>

  18. A.

     58

    B.

     59

    C.

     109

    D.

     108

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    <?php

    $i = 0;

    $x = $i++; $y = ++$i;

    print $x; print $y;

    ?>

  20. A.

     02

    B.

     12

    C.

     01

    D.

     21

    View Answer

    Workspace

    Discuss Discuss in Forum