3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { public $a = 'foo'; public function print() { echo $a.PHP_EOL; } } $i = (new A)->print(); $i->$a = 'i'; (clone $i)->print();
based on 0OIBO
Output for 7.1.0 - 7.2.0
Notice: Undefined variable: a in /in/T5O19 on line 5 Notice: Undefined variable: a in /in/T5O19 on line 10 Warning: Creating default object from empty value in /in/T5O19 on line 10 Fatal error: Uncaught Error: Call to undefined method stdClass::print() in /in/T5O19:12 Stack trace: #0 {main} thrown in /in/T5O19 on line 12
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Notice: Undefined variable: a in /in/T5O19 on line 5 Notice: Undefined variable: a in /in/T5O19 on line 10 Warning: Creating default object from empty value in /in/T5O19 on line 10 Fatal error: Uncaught Error: Cannot access empty property in /in/T5O19:10 Stack trace: #0 {main} thrown in /in/T5O19 on line 10
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/T5O19 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/T5O19 on line 5
Process exited with code 255.