Examveda
Examveda

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";
}
?>

A. hihellohi1

B. no output

C. hihi1

D. hi1

Answer: Option B

Solution(By Examveda Team)

As break is provided before print statement in case 2 it breaks the loop before printing.

This Question Belongs to PHP >> Control Structures(Loop In PHP)

Join The Discussion

Related Questions on Control Structures(Loop in PHP)