3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $a; public function __construct($a) { $this->a = (int) $a; } public static function extractA(self $aFoo) { return $aFoo->a; } } function max_by(array $aList, callable $aCallback) { return array_reduce($aList, function($carry, $item) use ($aCallback) { return ($carry == null || $aCallback($item) > $aCallback($carry)) ? $item : $carry; }); } $list = [ $foo1 = new Foo(2), $foo2 = new Foo(5), $foo3 = new Foo(1), ]; assert(max_by($list, ['Foo', 'extractA']) === $foo2);
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:
48.16 ms | 401 KiB | 8 Q