Home » PHP » PHP Switch Statement » Question
  1. What will be the output of the following PHP code ?
    <?php
    $opt = "1";
    switch($opt)
    {
    case 1:
    break;
    print "First Statement";
    case 2:
    print "Second Statement";
    break;
    default:
    print "Third Statement";
    }
    ?>
    1. First Statement
    2. Second Statement
    3. Third Statement
    4. Nothing
    5. None of these
Correct Option: D

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



Your comments will be displayed only after manual approval.