3v4l.org

run code in 500+ PHP versions simultaneously
<?php final class FromVariable { public static function run($filter, bool $variable = true, bool $variable2 = false) { $result = match (true) { $variable => 'a', $variable2 => 'b', default => throw new \InvalidArgumentException(), }; var_dump($result); } } FromVariable::run(false, true, false);
Output for 8.1.34, 8.2.0 - 8.2.34, 8.3.0 - 8.3.35, 8.4.1 - 8.4.26, 8.5.0 - 8.5.11
string(1) "a"

preferences:
28.78 ms | 1151 KiB | 7 Q