Home » PHP » PHP Functions » Question
  1. What will be the output of the following PHP code ?
    <?php
    function fun($opt)
    {
    switch($opt)
    {
    case 10:
    echo 'Case 10 will execute.';
    break;
    case 20:
    echo 'Case 20 will execute.';
    break;
    case 30:
    echo 'Case 30 will execute.';
    break;
    case 40:
    echo 'Case 40 will execute.';
    break;
    default:
    echo 'Default will execute.';
    break;
    }
    }
    fun(20);
    ?>
    1. Case 10 will execute.
    2. Case 20 will execute.
    3. Case 30 will execute.
    4. Case 40 will execute.
    5. Default will execute.
Correct Option: B

The switch statement is executed with $opt = 20.



Your comments will be displayed only after manual approval.