# PHP: Switch Case

Switch case used as an alternative to if-else-elseif to make it simpler to write conditions that are long and repeative.

We use PHP Switch case as follows for the example mentioned earlier:

<php>
\$sunlight = 0;
</php>

<php>
switch (\$sunlight){
case “0”:
echo “sunlight not present”;
break;
case “1”:
echo “sunlight present”;
break;

default:
echo “Not sure about sunlight”;
break;
}
</php>
This could have done using if-else-elseif also. But, using switch case simplies writing our code and understanding it. Also, note the <strong>default </strong>case in the switch statement.<br /></font>