ExamVeda
Login
Home
Operators and Expressions in php
?

What will be the output of the following PHP code ?
<?php
$y = 2;
if (--$y == 2 || $y xor --$y)
{
    echo $y;
}
?>

Answer & Solution
Correct Answer: Option B
–$y == 2 is false but y is decremented, the xor gives true if only one of the operands are true, thus 1 xor 0 is true.
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.