Code:
switch ($_GET['operation']) {
case "professionist":
case "company":
case "student":
echo "ok<br>";
case "professionist":
echo "inprofessionist<br>";
break;
case "company":
echo "incompany<br>";
break;
default:
echo "Meh!<br>";
break;
}
My goal is to execute some (common to professionist/company/student) code first, and then execute the rest of the code depending on the operation…
The problem is that the first 3 cases works perfectly, but then, if for example the operation is “company”, the switch go on “professionist” case, what i’m doing wrong? How can improve that? Thanks in advance…
That’s how switch works. If you always need to print “ok” then move it outside switch: