xref: /PHP-8.0/Zend/tests/match/004.phpt (revision 9fa1d133)
1--TEST--
2Match expression with true as expression
3--FILE--
4<?php
5
6function get_range($i) {
7    return match (true) {
8        $i >= 50 => '50+',
9        $i >= 40 => '40-50',
10        $i >= 30 => '30-40',
11        $i >= 20 => '20-30',
12        $i >= 10 => '10-20',
13        default => '0-10',
14    };
15}
16
17echo get_range(22) . "\n";
18echo get_range(0) . "\n";
19echo get_range(59) . "\n";
20echo get_range(13) . "\n";
21echo get_range(39) . "\n";
22echo get_range(40) . "\n";
23
24?>
25--EXPECT--
2620-30
270-10
2850+
2910-20
3030-40
3140-50
32