Source: stitcher.io

PHP 8: match or switch?

Category: PHP

If you enjoy reading my blog, you could consider supporting me on Patreon. A powerful feature that will often be the better choice to using switch.

So you have the same functionality as switch in this regards, but with less writing, and less ways to screw up.

The match expression will start by resolving the first arm's condition, stop if it evaluates to true, and so on.

If I'd need to summarise the match expression in one sentence, I'd say it's the stricter and more modern version of it's little switch brother.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners