Current course:

PHP Switch


A switch (also called a "case statement) is used instead of an IF ELSE statements when comparing one variable against many possible matches.

Example

$name = "Dave";
switch($name) {
      case "John":
            echo "You're ok.";
            break;
      case "Bill":
            echo "Meh.";
            break;
      case "Dave":
            echo "You're so 1337!";
            break;
      case "Frank":
            echo "lin Roosevelt.";
            break;
      default":
            echo "You're not in my list of names.";
            break;
}