Examveda
Examveda

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

A. error

B. 2

C. hi

D. how are u

Answer: Option B

Solution(By Examveda Team)

Enters if else as first condition is false and thus x is set to 2.

Join The Discussion

Related Questions on Control Structures(Loop in PHP)