Learn web design and programming with our free video and text tutorials.
Web Designer? Design and market your own professional website with easy-to-use tools.
Browse our HTML, XHTML and CSS tutorials to learn how to create your website at LearnWebsiteDesign.com or download one of our free website templates.
Providing high quality free software to download
PHP switch statements allows you to set up a list of conditions with a block of statements for each condition. The switch statement tests the value of one variable and executes the block of statements for the matching variable, or cases.
<?php
$state = "TX";
switch($state){
case "CA";
echo "I live in California";
break;
case "NY";
echo "I live in New York";
break;
case "TX";
echo "I live in Texas.";
break;
}
?>
The code above outputs:
I live in Texas.