What is the 'Match' expression in PHP 8, and how does it differ from a 'Switch' statement?
Last updated
matchis an expression that returns a value you can assign directly, whileswitchis a statement that only executes blocks.matchuses strict===comparison (no type juggling) and has no fallthrough, so nobreakis needed.switchuses loose==.An unmatched value throws
UnhandledMatchErrorinstead of silently doing nothing. Multiple conditions can share one arm using commas.