submitted by: Guest

PHP: switch - strings

switch example using strings


code snippet:
<?php
// switch example using strings
$creature="dragon";

switch (
$creature){

    case 
"rat":
     echo 
"a $creature says: eek eek eek";
       break;

  case 
"dragon":
      echo 
"a $creature says: nice to eat you";
       break;

  case 
"pig":
     echo 
"a $creature says: oink oink oink";
        break;

  default:
        echo 
"I have not heard of this creature";
       break;
  

?>

sample output:
a dragon says: nice to eat you