PHP Operators


  1. What will be the output of the following PHP code ?
    <?php
    $n = 9;
    while (++$n)
    {
    while (--$n > 0)
    print $n;
    }
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    The loop never ends as n is always incremented and then decremented.


  1. What will be the output of the following PHP code ?
    <?php
    echo 7 * 5 / 4 + 10;
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Operator precedence order must be followed.



  1. What will be the output of the following PHP code ?
    <?php
    echo 10 * 15 / 12 + 14
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Operator precedence order must be followed.


  1. What will be the output of the following PHP code ?
    <?php
    $n = 10;
    $m = 10;
    if ($n && ($m = $n + 10)) {
    echo "True";
    }
    echo $m;
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    In if condition when the first case is 10 and is an && operation then the second command is executed.



  1. What will be the output of the following PHP code ?
    <?php
    $p = 20;
    $q = 10;
    if ($p || ($q = $p + 10)) {
    echo "True";
    }
    echo $q;
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    In if condition when the first case is 1 and is an || operation then the second command is not executed.