Home » PHP » PHP Operators » Question
  1. What will be the output of the following PHP code ?
    <?php
    $k = 4;
    if (--$k == 4 || $k xor --$k)
    {
    echo $k;
    }
    ?>
    1. Error
    2. 0
    3. 4
    4. 44
    5. None of these
Correct Option: B

–$k == 4 is false but k is decremented, the xor gives true if only one of the operands are true, thus 1 xor 0 is true.



Your comments will be displayed only after manual approval.