3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SomeClass { static function staticMethod(){ echo "SomeClass::staticMethod()"; } } class Dynamic extends stdClass{ public function __call($key,$params){ if(!isset($this->{$key})) throw new Exception("Call to undefined method ".get_class($this)."::".$key."()"); call_user_func_array($$this->{$key},$params); } } $dynamic = new Dynamic; $dynamic->myMethod = "thatFunction"; $dynamic->hisMethod = array($dynamic,"aMethod"); $dynamic->newMethod = array("SomeClass","staticMethod"); $dynamic->anotherMethod = function(){ echo "Hey there"; }; echo("<pre>"); $dynamic->newMethod(); echo("</pre>");
Output for git.master, git.master_jit, rfc.property-hooks
<pre> Fatal error: Uncaught Error: Object of class Dynamic could not be converted to string in /in/J39XV:13 Stack trace: #0 /in/J39XV(26): Dynamic->__call('newMethod', Array) #1 {main} thrown in /in/J39XV on line 13
Process exited with code 255.

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:
50.09 ms | 401 KiB | 8 Q