3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 7.1.0 - 7.2.0
<pre> Recoverable fatal error: Object of class Dynamic could not be converted to string in /in/J39XV on line 13
Process exited with code 255.
Output for 5.3.19 - 7.0.20
<pre> Catchable fatal error: Object of class Dynamic could not be converted to string in /in/J39XV on line 13
Process exited with code 255.