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

Print returns 1,thus it gives case 1.



Your comments will be displayed only after manual approval.