3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { public $a = 'foo'; public function print() { echo $this->a.PHP_EOL; } } $i = (new A)->print(); $i->a = 'i'; (clone $i)->print();
based on IM4Kv
Output for 7.0.0 - 7.2.0
foo Warning: Creating default object from empty value in /in/QIvUc on line 10 Fatal error: Uncaught Error: Call to undefined method stdClass::print() in /in/QIvUc:12 Stack trace: #0 {main} thrown in /in/QIvUc on line 12
Process exited with code 255.
Output for 5.4.1 - 5.6.28
Parse error: syntax error, unexpected 'print' (T_PRINT), expecting identifier (T_STRING) in /in/QIvUc on line 5
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected T_PRINT, expecting T_STRING in /in/QIvUc on line 5
Process exited with code 255.