This site is mobile accessible. Press the "Tap Here" button to use a different font-size.


Smartphone icons created by Freepik - Flaticon

PHP Switch

The PHP switch Statement

Your favorite color is neither red, blue, nor green!

<?php
// define $favcolor
$favcolor = "yellow";

switch ($favcolor) {
  case "red":
    echo "Your favorite color is red!";
    break;
  case "blue":
    echo "Your favorite color is blue!";
    break;
  case "green":
    echo "Your favorite color is green!";
    break;

// favcolor does not match any case color
  default:
    echo "Your favorite color is neither red, blue, nor green!";
}
?>