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'); }, $things)); var_dump(array_map(function ($thing) { return is_callable($thing) && !is_string($thing); }, $things));
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) } array(6) { [0]=> bool(true) [1]=> bool(true) [2]=> bool(true) [3]=> bool(false) [4]=> bool(false) [5]=> bool(false) } array(6) { [0]=> bool(true) [1]=> bool(true) [2]=> bool(true) [3]=> bool(false) [4]=> bool(true) [5]=> bool(true) }

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:
45.29 ms | 402 KiB | 8 Q