Examveda
Examveda

What will be the output of the following PHP code ?
<?php
$x = 0;
if ($x++)
    print "hi";
else
    print "how are u";
?>

A. hi

B. no output

C. error

D. how are u

Answer: Option D

Solution(By Examveda Team)

x is incremented after if which evaluates to false.

Join The Discussion

Related Questions on Control Structures(Loop in PHP)