What will be the output of the following PHP code ?
<?php
$a = "1";
switch ($a)
{
case 1:
print "hi";
case 2:
print "hello";
default:
print "hi1";
}
?>
<?php
$a = "1";
switch ($a)
{
case 1:
print "hi";
case 2:
print "hello";
default:
print "hi1";
}
?>
A. hihellohi1
B. hi
C. hihi1
D. hi1
Answer: Option A
Solution(By Examveda Team)
As break is not provided it executes all the cases.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