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.29, 8.2.0 - 8.2.23, 8.3.0 - 8.3.11
Do something before the func call. 23 Do something after the func call.

preferences:
44.6 ms | 406 KiB | 5 Q