×

Multiple-Choice Questions

Web Technologies MCQs

Computer Science Subjects MCQs

Databases MCQs

Programming MCQs

Testing Software MCQs

Digital Marketing Subjects MCQs

Cloud Computing Softwares MCQs

AI/ML Subjects MCQs

Engineering Subjects MCQs

Office Related Programs MCQs

Management MCQs

More

What will be the output of the following PHP code (21)?

90. What will be the output of the following PHP code?

<?php
$car = "Honda";

switch ($car) {
    case "Honda":
        echo "You selected Honda.";
    case "BMW":
        echo "You selected BMW.";
    case "AUDI":
        echo "You selected Audi.";
    default:
        echo "None is selected.";
}
?>
  1. You selected Honda.
  2. You selected Honda.You selected BMW.
  3. You selected Honda.You selected BMW.You selected Audi.
  4. You selected Honda.You selected BMW.You selected Audi.None is selected.

Answer: D) You selected Honda.You selected BMW.You selected Audi.None is selected.

Explanation:

In the above PHP Script, break statements were not used in the case blocks. The value of $car is "Honda", so the first case executes and then all other blocks will be executed because the switch statement executes the blocks from the matched case block to the bottom if the break statement is not there.

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.