Examveda
Examveda

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

A. 2

B. 1

C. 3

D. no output

Answer: Option A

Solution(By Examveda Team)

First $y = 2 is compared to and then decremented, then incremented and compared to $y = 2.

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

Join The Discussion

Related Questions on Operators and Expressions in php