switch in php

The switch statement works in a similar way to the if statement, but it allows the condition to take more than two values. In an if statement, the condition can be either true or false. In a switch statement, the condition can take any number of different values, as long as it evaluates to a simple type (integer, string, or float)

Example of switch in php

switch($find) {
 case "a" :
 echo "<p>Regular customer.</p>";
 case "b" :
 echo "<p>Customer referred by TV advert.</p>";
 case "c" :
 echo "<p>Customer referred by phone directory.</p>";
 case "d" :
 echo "<p>Customer referred by word of mouth.</p>";
 default :
 echo "<p>We do not know how this customer found us.</p>";

Leave a Comment