php switch

-6 points

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;    
}
?>

Created by Anonymous 20 weeks 5 days ago
  Tags:

Answer(s):

-4 points

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

Created by Anonymous

Post your Answer

  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Links to specified hosts will have a rel="nofollow" added to them.

More information about formatting options