Please note, this is a STATIC archive of website webdevelopmenttutorials.com from 20 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.

Tutorials

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.

PHP Switch Statements Tutorial

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.