Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for How to use “match” with PHP 8 🎯
Pierre-Henry Soria ✨
Pierre-Henry Soria ✨

Posted on • Edited on

     

How to use “match” with PHP 8 🎯

Let's usematch expression with PHP 8.0 💪 Lets' see when to use it and why it can have advantages over the old goodswitch statement.
match will indeed make your code cleaner, less verbose and easier to read 💥

Furthermore, with the “https://php.watch/versions/8.0/match-expression” expression, you can have multiple matching conditions separated by commas, like

$sMessage=match($sDayPrefix){'Sat','Sun'=>'Enjoy your weekend!',};
Enter fullscreen modeExit fullscreen mode

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

👋Pierre-Henry. A Passionate Software Engineer😎 I create cool stuff (https://github.com/Lifyzer & https://github.com/pH7Software), love programming, eating fruits, developing & applying new skills 😊
  • Location
    🌴 Australia 🥥
  • Education
    James Cook University
  • Work
    Senior Software Engineer at Updoc
  • Joined

More fromPierre-Henry Soria ✨

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp