PHP If Else/Else If Statement


  1. What will be the output of the following PHP code ?
    <?php
    $p = 22;
    if ($p-- - --$p - $p)
    print "Interview";
    else
    print "Mania";
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Computing the expression in the if clause,it sums upto to 2 which is a positive value.


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











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    The . operator appends a string and returns true.



  1. What will be the output of the following PHP code ?
    <?php
    $s = "hey";
    if (strlen($s))
    print strlen($s);
    else
    print "nice";
    ?>











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    The function strlen($s) gives the length of the string,5, which is considered true.