3v4l.org

run code in 300+ PHP versions simultaneously
<?php $conditions = 'condition_2'; $foo = match ($conditions) { 'condition_1' => 'some text', 'condition_2' => (function () { $result = 'crazy'; // crazy programming return $result; })() }; var_dump($foo);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.14
string(5) "crazy"
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in /in/gWS2j on line 5
Process exited with code 255.

preferences:
99.84 ms | 407 KiB | 5 Q