Examveda
Examveda

What will be the output of the following PHP code ?
<?php
$x = 1;
$y = 2;
if (++$x == $y++)
{
    echo "true ", $y, $x;
}
?>

A. no output

B. true 23

C. true 22

D. true 33

Answer: Option B

Solution(By Examveda Team)

x is preincremented and y is post incremented thus both are 2 in the if condition, later y is incremented.

This Question Belongs to PHP >> Operators And Expressions In Php

Join The Discussion

Related Questions on Operators and Expressions in php