0

What is the optimal maximum amount of elseifs in one if statement to manage them easily?

17th Sep 2016, 10:23 AM
Rene Tse
Rene Tse - avatar
2 Answers
+ 3
you can use as amany as u wish but i suggest the switch is best
3rd Oct 2016, 2:25 PM
Czar opiyo
Czar opiyo - avatar
+ 2
If you find yourself using a lot of "elseif"s like this <?php if ($a > $b) { echo "a is bigger than b"; } elseif ($a == $b) { echo "a is equal to b"; } elseif (...) { echo "..."; } elseif (...) { echo "..."; } elseif (...) { echo ""; } elseif (...) { echo ""; } else { echo "a is smaller than b"; } ?> then you should look at using switch construction instead: http://php.net/manual/en/control-structures.switch.php
20th Sep 2016, 4:42 AM
Pavel Rotaru