3v4l.org

run code in 300+ PHP versions simultaneously
<?php function decorate(callable $func): callable { return function (mixed ...$args) use ($func): mixed { echo "Do something before the func call.", PHP_EOL; $result = $func(...$args); echo "Do something after the func call.", PHP_EOL; return $result; }; } // ------------------------------------------------------- $func = function (int $x): void { echo $x, PHP_EOL; }; $func = decorate($func); $func(x: 23);
Output for 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.14
Do something before the func call. 23 Do something after the func call.

preferences:
42.61 ms | 406 KiB | 5 Q