The switch statement in PHP is great when you want check condition on the same expression without incorporating many if statements altogether.
Now, this looks fine in comparison to the if-else statement as you don’t have to explicitly compare the expression explicitly.
An alternative for switch statement called “Match expression” has been accepted in this RFC. The RFC proposes adding a new match expression that is similar to switch but with safer semantics and the ability to return values.
Follow me on Twitter @amit_merchant Match expression - An alternative to switch statement in PHP 8 This experimental CSS Overview feature of Chrome is awesome The many ways to take screenshots on Ubuntu Get your blog running in seconds with Jekyll in 2020 Change URL query parameters using JavaScript