3v4l.org

run code in 300+ PHP versions simultaneously
<?php function decorate(callable $fn, array $decorators, array $arguments = array()) { foreach (array_reverse($decorators) as $decorator) { if (is_callable($decorator)) { $fn = $decorator($fn); } } return call_user_func_array($fn, $arguments); } function decorator(callable $decorator) { // This function replaces 'trace' return function($wrapped) use ($decorator) { // This function replaces the function which 'trace' is used on. return function() use ($wrapped, $decorator) { $arguments = func_get_args(); return call_user_func($decorator, $wrapped, $arguments); }; }; } function _trace(callable $fn, array $arguments) { printf("Calling %s with arguments %s\n", print_r($fn, true), print_r($arguments, true)); return call_user_func_array($fn, $arguments); } function trace() { return decorate('_trace', ['decorator'], func_get_args()); } function _foo() { echo "Foo"; } function foo() { return decorate('_foo', ['trace'], func_get_args()); }
Output for git.master, git.master_jit, rfc.property-hooks

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
51.27 ms | 401 KiB | 8 Q