What will be the output of the following PHP code?
<?php
$team = "arsenal";
switch ($team)
{
case "manu":
echo "I love man u";
case "arsenal":
echo "I love arsenal";
case "manc":
echo "I love manc";
}
?>
<?php
$team = "arsenal";
switch ($team)
{
case "manu":
echo "I love man u";
case "arsenal":
echo "I love arsenal";
case "manc":
echo "I love manc";
}
?>
A. I love arsenal
B. Error
C. I love arsenalI love manc
D. I love arsenalI love mancI love manu
Answer: Option C
Solution(By Examveda Team)
If a break statement isn’t present, all subsequent case blocks will execute until a break statement is located.Join The Discussion
Comments ( 1 )
Related Questions on Basic PHP
A. Both 1 and 3
B. Both 2 and 4
C. Only 2
D. Both 1 and 2
Which of the following is/are a PHP code editor?
1. Notepad
2. Notepad++
3. Adobe Dreamweaver
4. PDT
A. Only 4
B. All of the mentioned
C. 1, 2 and 3
D. Only 3
A. All of the mentioned.
B. Only 2
C. 2 and 3
D. 2, 3 and 4
In this question, you didn't mention default after end of case. so, whenever we try to execute this code we got first option which is correct but here displayed option C is correct .. so please correct this question. mention default otherwise set correct question.