No, you can’t. A is a switchvalue of type
switch ($a) {
case 1:
break;
case 2:
break;
}
which actually matches
if ($a == 1) {
} else if ($a == 2) {
}
You can use a slightly different design
switch (true) {
case $firstVal == "YN" && $secondVal == "NN":
break;
case $firstVal == "YY" && $secondVal == "NN":
break;
}
which is equivalent
if (true == ($firstVal == "YN" && $secondVal == "NN")) {
} else if (true == ($firstVal == "YY" && $secondVal == "NN")) {
}
In some cases its much more readable than the infinite- if-elseif-elsechain.
source
share