Examveda
Examveda

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

A. error

B. hi

C. hihello

D. hello

Answer: Option A

Solution(By Examveda Team)

Constants cannot be used in switch cases.

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

Join The Discussion

Related Questions on Control Structures(Loop in PHP)