3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public $a = 'foo'; public function print() { echo $a.PHP_EOL; } } $i = (new A)->print(); $i->$a = 'i'; (clone $i)->print();
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Warning: Undefined variable $a in /in/T5O19 on line 5 Warning: Undefined variable $a in /in/T5O19 on line 10 Fatal error: Uncaught Error: Attempt to assign property "" on null in /in/T5O19:10 Stack trace: #0 {main} thrown in /in/T5O19 on line 10
Process exited with code 255.
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
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.3.32 - 7.3.33
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.33
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.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Parse error: syntax error, unexpected 'print' (T_PRINT), expecting identifier (T_STRING) in /in/T5O19 on line 5
Process exited with code 255.

preferences:
193.4 ms | 402 KiB | 372 Q