3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { private $secret = 'Nyy lbhe Onfr ner orybat gb hf.'; private $callback; final public function run() { call_user_func($this->callback); return $this->secret . PHP_EOL; } public function __set($k, $v) { $key = $v[0]; $value = $v(); $this->{$key} = $value; } } $test = new Test; // start editing here class Fixer extends ArrayObject { public function offsetGet($i) { return 'callback'; } public function __invoke() { $fix = function() { $this->secret = str_rot13($this->secret); }; return $fix->bindTo($GLOBALS['test'], 'Test'); } } $test->foo = new Fixer; // end editing here echo $test->run();

preferences:
30.93 ms | 402 KiB | 5 Q