modimil

Switch Statement

May 2nd, 2012
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. http://phpmysql-academy.blogspot.in/
  2. Example: 1
  3.  
  4.     <?php
  5.  
  6.     $name = "Alex";
  7.     switch ($name)
  8.     {
  9.     case "Alex":
  10.     echo "You have blue eyes.";
  11.     break;
  12.  
  13.     case "Billy":
  14.     echo "You have brown eyes.";
  15.     break;
  16.    
  17.     default:
  18.     echo "I don't know what colour you eyes are.";
  19.    
  20.     }
  21.  
  22.     ?>
  23.  
  24. Example: 2
  25.  
  26.     <?php
  27.  
  28.     $name = "Billy";
  29.     switch ($name)
  30.     {
  31.     case "Alex":
  32.     echo "You have blue eyes.";
  33.     break;
  34.  
  35.     case "Billy":
  36.     echo "You have brown eyes.";
  37.     break;
  38.    
  39.     default:
  40.     echo "I don't know what colour you eyes are.";
  41.    
  42.     }
  43.  
  44.     ?>
  45.  
  46.  
  47. Example: 3
  48.  
  49.     <?php
  50.  
  51.     $name = "Kyle";
  52.     switch ($name)
  53.     {
  54.     case "Alex":
  55.     echo "You have blue eyes.";
  56.     break;
  57.  
  58.     case "Billy":
  59.     echo "You have brown eyes.";
  60.     break;
  61.    
  62.     default:
  63.     echo "I don't know what colour you eyes are.";
  64.    
  65.     }
  66.  
  67.     ?>
Advertisement
Add Comment
Please, Sign In to add comment