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:
$sunlight = 0;
|
This could have done using if-else-elseif also. But, using switch case simplies writing our code and understanding it. Also, note the default case in the switch statement.