3v4l.org

run code in 300+ PHP versions simultaneously
<?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() { $self = new stdobject(); $self->init = function ($params) use ($self) { $self->_opmode = &$params['opmode']; }; $self->setup = function () use ($self) { $self->_opmode = 'dog'; }; $self->print = function () use ($self) { echo $self->_opmode . "\n"; }; return $self; }; $obj = $mod(); $reference = 'fish'; $obj->init(['opmode' => &$reference]); $obj->print(); // fish $obj->setup(); $obj->print(); // dog $reference = 'cats'; $obj->print(); // cats
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property stdobject::$init is deprecated in /in/SLAri on line 16 Deprecated: Creation of dynamic property stdobject::$setup is deprecated in /in/SLAri on line 20 Deprecated: Creation of dynamic property stdobject::$print is deprecated in /in/SLAri on line 24 Deprecated: Creation of dynamic property stdobject::$_opmode is deprecated in /in/SLAri on line 17 fish dog cats

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:
67.74 ms | 402 KiB | 8 Q