Home » PHP » PHP Switch Statement » Question
  1. What will be the output of the following PHP code ?
    <?php
    $s = 2.2;
    switch($s)
    {
    case 2.1:
    print "Option A";
    break;
    case 2.2:
    print "Option B";
    break;
    default:
    print "Option C";
    }
    ?>
    1. Error
    2. Option A
    3. Option B
    4. Option C
    5. None of these
Correct Option: C

it compares it with 2.2 and thus prints Option B and exits.



Your comments will be displayed only after manual approval.