xref: /php-src/Zend/tests/match/046.phpt (revision 226b92b1)
1--TEST--
2Nested match expressions
3--FILE--
4<?php
5
6// Nested in return expression:
7$b = 'b';
8echo match($b) {
9    'a' => 1,
10    'b' => match (1) {
11        strpos('ab', $b) => 100,
12        default => 15
13    },
14    default => 4
15};
16
17echo "\n";
18
19// Nested in condition expression:
20$c = 'c';
21echo match($c) {
22    'foo' => 'bar',
23    match ($c) { default => 'c' } => 300
24};
25
26echo "\n";
27
28// Nested in one of many condition expressions:
29$d = 'd';
30echo match($d) {
31    'foo' => 'bar',
32    match ($d) { default => 'd' },
33    match ($d) { default => 'e' } => 500
34};
35
36
37?>
38--EXPECT--
39100
40300
41500
42