PHPSyntax
Match Expression
Code example
$label = match ($n) {
1 => 'one',
default => 'other',
};Returns a value based on strict matches.
In PHP, match expression: returns a value based on strict matches — $label = match ($n) { 1 => 'one', default => 'other', };
$label = match ($n) {
1 => 'one',
default => 'other',
};$label = match ($n) {
1 => 'one',
default => 'other',
};Returns a value based on strict matches.
Use $label = match ($n) { 1 => 'one', default => 'other', };.
Use this pattern: $label = match ($n) { 1 => 'one', default => 'other', };
Yes. Use Copy code and adapt the example to your program.
No. The language syntax is the same across operating systems.