What will be the output of the following PHP code ?
<?php
$a = "1";
$a = 1;
$b = 1;
switch($a)
{
case $a * $b:
print "hi";
break;
case $a / $b:
print "hello";
break;
default:
print "hi1";
}
?>
<?php
$a = "1";
$a = 1;
$b = 1;
switch($a)
{
case $a * $b:
print "hi";
break;
case $a / $b:
print "hello";
break;
default:
print "hi1";
}
?>
A. hihellohi1
B. hi
C. hihello
D. hi1
Answer: Option B
Solution(By Examveda Team)
It checks the first case, when it finds it equal it will perform it breaks out.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