3v4l.org

run code in 300+ PHP versions simultaneously
<?php function any($elements, Clousure $x){ foreach($elements as $element){ if($x($element)) return true; } return false; } function all($elements, Clousure $x){ foreach($elements as $element){ if(!$x($element)) return false; } return true; } function minimum($of) { return function($el) use ($of){ if($el < $of) return true; return false; }; } echo "any x <- [1, 2, 3, 4, 5] | < 5" . PHP_EOL; if(any(array(1, 2, 3, 4, 5), minimum(5))) { echo "true" . PHP_EOL; } else { echo "false" . PHP_EOL; }; echo "all x <- [1, 2, 3, 4] | < 5" . PHP_EOL; if(all(array(1, 2, 3, 4), minimum(5))) { echo "true" . PHP_EOL; } else { echo "false" . PHP_EOL; };
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
any x <- [1, 2, 3, 4, 5] | < 5 Fatal error: Uncaught TypeError: any(): Argument #2 ($x) must be of type Clousure, Closure given, called in /in/UUe6i on line 29 and defined in /in/UUe6i:3 Stack trace: #0 /in/UUe6i(29): any(Array, Object(Closure)) #1 {main} thrown in /in/UUe6i on line 3
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
any x <- [1, 2, 3, 4, 5] | < 5 Fatal error: Uncaught TypeError: Argument 2 passed to any() must be an instance of Clousure, instance of Closure given, called in /in/UUe6i on line 29 and defined in /in/UUe6i:3 Stack trace: #0 /in/UUe6i(29): any(Array, Object(Closure)) #1 {main} thrown in /in/UUe6i on line 3
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
any x <- [1, 2, 3, 4, 5] | < 5 Catchable fatal error: Argument 2 passed to any() must be an instance of Clousure, instance of Closure given, called in /in/UUe6i on line 29 and defined in /in/UUe6i on line 3
Process exited with code 255.

preferences:
170.83 ms | 402 KiB | 183 Q