1. Computing & Technology

Discuss in my forum

Switch () PHP Function

By , About.com Guide

See More About:
Definition: The PHP function switch () is used in place of several IF / ELSEIF statements. The default is optional, and is used if no other case is true. If you do not use a break; then all statements below your original statement will be treated as true.
Also Known As: Switch Loop
Examples:
 <?php 
 switch ($i)
 {
 case 0:
 echo "Zero";
 break;
 case 1:
 echo "One";
 break;
 case 2:
 echo "Two";
 break;
 default:
 echo "Choose a different number";
 }
 ?> 

©2012 About.com. All rights reserved.

A part of The New York Times Company.