Examveda
Examveda

What will be the output of the following PHP code ?
<?php
$a = "2";
switch ($a)
{
case 1:
    print "hi";
case 2:
    print "hello";
    break;
default:
    print "hi1";
}
?>

A. hihellohi1

B. hello

C. hihi1

D. hi1

Answer: Option B

Solution(By Examveda Team)

As hello is provided after case2 it breaks the loop.

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

Join The Discussion

Related Questions on Control Structures(Loop in PHP)