3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private $name; public function __construct($name) { $this->name = $name; } } $person = new A("Tim"); function test() { return $this->name; } $f = function() { return $this->name; }; $cl = Closure::fromCallable( $f ); echo $cl->bindTo($person, 'A')(); echo "\n\nBut, Closure::fromCallable problematic:\n"; try { $cl = Closure::fromCallable( "test" ); echo $cl->bindTo($person, 'A')(); } catch (Error $e) { echo "Unable to bind closure from callable because: \n"; echo $e->getMessage(); }
Output for git.master, git.master_jit, rfc.property-hooks
Tim But, Closure::fromCallable problematic: Warning: Cannot rebind scope of closure created from function in /in/qso7b on line 26 Unable to bind closure from callable because: Value of type null is not callable

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:
49.46 ms | 2015 KiB | 4 Q