PHP Operators


  1. What will be the output of the following PHP code ?
    <?php
    $p = 12;
    echo ++$p;
    echo $p++;
    echo $p;
    echo ++$p;
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    ++$p increments a and then prints it,$p++ prints and then increments.


  1. What will be the output of the following PHP code ?
    <?php
    $m = 8;
    echo $m = ++$m % 9 + ++$m;
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Evaluation done from right to left.



  1. What will be the output of the following PHP code ?
    <?php
    $str = 'view';
    echo 'Inter{$str}Mania';
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Inter{$str}Mania, single quotes are not parsed.


  1. What will be the output of the following PHP code ?
    <?php
    $str = 'view';
    print "Inter".$str."Mania";
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    dereferences the variable/string within.



  1. What will be the output of the following PHP code ?
    <?php
    $str = 'view ';
    print "Inter{$str}Mania";
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    {$}dereferences the variable within.