?
What will be the output of the following PHP code ?
What will be the output of the following PHP code ?
<?php
$a = "1";
switch($a)
{
case 1:
break;
print "hi";
case 2:
print "hello";
break;
default:
print "hi1";
}
?>
<?php
$a = "1";
switch($a)
{
case 1:
break;
print "hi";
case 2:
print "hello";
break;
default:
print "hi1";
}
?>
Answer & Solution
Correct Answer:
Option
B
As break is provided before print statement in case 2 it breaks the loop before printing.
Join the Discussion
Login to post a comment or share your explanation.
Login