What will be the output of the following PHP code ?
<?php
$b = 1;
switch($b)
{
case 1.0:
print "hi";
break;
case 1:
print "hello";
break;
default:
print "hi1";
}
?>
<?php
$b = 1;
switch($b)
{
case 1.0:
print "hi";
break;
case 1:
print "hello";
break;
default:
print "hi1";
}
?>
A. hihellohi1
B. hi
C. hihello
D. hello
Answer: Option A
Solution(By Examveda Team)
Upcasting does happen in case,it compares it with 1.0 and thus prints hi and exits.Related Questions on Control Structures(Loop in PHP)
A. how are u
B. hi
C. error
D. no output
A. hi
B. no output
C. error
D. how are u
A. how are uhello
B. hihello
C. hi
D. no output
A. true
B. false
C. error
D. no output
Join The Discussion