3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php if (debug_backtrace()) { return new class { public $bar; public function bing($foo = null) { if ($foo) $foo->bing(); } }; } $oldFoo = require(__FILE__); $newFoo = require(__FILE__); var_dump(get_class_methods($oldFoo)); var_dump(get_object_vars($oldFoo)); $newFoo->bing($oldFoo);
Output for 7.0.20 - 7.2.8
array(1) { [0]=> string(4) "bing" } array(1) { ["bar"]=> NULL }
Output for 7.0.0 - 7.0.8
array(1) { [0]=> string(3) "bar" } array(0) { } Fatal error: Uncaught Error: Call to undefined method class@anonymous::bing() in /in/H4q8L:7 Stack trace: #0 /in/H4q8L(18): class@anonymous->bing(Object(class@anonymous)) #1 {main} thrown in /in/H4q8L on line 7
Process exited with code 255.
Output for 5.6.0 - 5.6.23
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/H4q8L on line 4
Process exited with code 255.