php switch



switch/case is very similar or an alternative to the if/elseif/else commands. Switch is normally used when you are finding an exact (equal) result instead of a greater or less than result.

<?php
switch ($phpswitch){
    case 
"0":
        echo 
"php switch case is 0";
        break;
    case 
"1":
        echo 
"php switch case is 1";
        break;    
    
    default:
        echo 
"This is default php case. executed when 0 and 1 do not happen";
        break;    
}
?>



Also, refer php case. php switch case. Switch case used as an alternative to if-else-elseif in PHP or any other language to make it simpler to write conditions that are long and repeative.