php Tutorials
Creating An RSS Feed With PHP And MySQL
Retrieving XML With Curl and SimpleXML
Using curl to Query Remote Servers
MySQL Basics
PHP mySQL Voting Booth
File Download Security
PHP Fundamentals

PHP Fundamentals

switch ... case is an alternative to if...else. can only be used if all conditions are based around one variable. This method the variable is declared once at the begining and then conditions are called.

switch ($sport) {
  case "1":
  echo "Basketball";
  case "2":
  echo "Baseball";
  case "3":
  echo "Football";
  case "4":
  echo "Hockey";
  case "5":
  echo "Golf";
  case "6":
  echo "Soccer";
  echo "None";

Switch starts the process. Each condition is represented by case and ended with a break. Notice case ends with a : not a semicolon. Default is used if none of the cases matches the variable.

Math Functions and Flow Control <<  1 2 3 4 5 6  >> Loops
New Content