<?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(); }
You have javascript disabled. You will not be able to edit any code.
Value for `_results` contains invalid data `array`