@ 2016-11-03T10:16:36Z <?php
class stdobject {
public function __call($method, $arguments) {
if (isset($this->{$method}) && is_callable($this->{$method})) {
return call_user_func_array($this->{$method}, $arguments);
} else {
throw new Exception("Fatal error: Call to undefined method: $method");
}
}
}
$mod = function() {
$test = new stdobject();
$opmode=null;
$mode='somemode';
$ref2=&$mode;
$test->init = function ($params) use (&$opmode) {
$opmode = &$params['opmode'];
};
$test->setup = function () use (&$opmode,&$mode) {
$opmode = 'test';
$mode='someothermode';
};
$test->print=function() use (&$opmode,&$mode){
echo $opmode;
echo $mode;
};
return $test;
};
$test = $mod();
$opmode = 'helloworld';
$test->init(['opmode' => &$opmode]);
$test->setup();
$test->print();
echo $opmode;
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.2.0 - 8.2.19 , 8.3.0 - 8.3.7 Deprecated: Creation of dynamic property stdobject::$init is deprecated in /in/3YEkB on line 20
Deprecated: Creation of dynamic property stdobject::$setup is deprecated in /in/3YEkB on line 24
Deprecated: Creation of dynamic property stdobject::$print is deprecated in /in/3YEkB on line 29
testsomeothermodehelloworld Output for 5.6.0 - 5.6.27 , 7.0.0 - 7.0.20 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 testsomeothermodehelloworld preferences:dark mode live preview
166.86 ms | 403 KiB | 221 Q