3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Stuff { function __invoke() { return 'I am ' . get_class($this) . '.'; } } class Thing { function __invoke() { return 'I am Thing.'; } } class Thang { use Stuff; } $things[] = function () { return 'I am Thong.'; }; $things[] = new Thing; $things[] = new Thang; $things[] = 'strlen'; $things[] = [$things[0], '__invoke']; $things[] = [$things[1], '__invoke']; var_dump(array_map('is_callable', $things)); var_dump(array_map(function ($thing) { return is_object($thing) && method_exists($thing, '__invoke'); })); var_dump(array_map(function ($thing) { return is_callable($thing, '__invoke') && !is_string($thing); }));
Output for git.master, git.master_jit, rfc.property-hooks
array(6) { [0]=> bool(true) [1]=> bool(true) [2]=> bool(true) [3]=> bool(true) [4]=> bool(true) [5]=> bool(true) } Fatal error: Uncaught ArgumentCountError: array_map() expects at least 2 arguments, 1 given in /in/P1AN7:14 Stack trace: #0 /in/P1AN7(14): array_map(Object(Closure)) #1 {main} thrown in /in/P1AN7 on line 14
Process exited with code 255.

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:
39.03 ms | 401 KiB | 8 Q