3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Fruit { public $name; public $color; function __construct($name) { $this->name = $name; } function get_name() { return $this->name; } } $Fruit = new Fruit("Apple"); echo $apple->get_name();
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 $apple in /in/5cGnY on line 16 Fatal error: Uncaught Error: Call to a member function get_name() on null in /in/5cGnY:16 Stack trace: #0 {main} thrown in /in/5cGnY on line 16
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.3.33, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Notice: Undefined variable: apple in /in/5cGnY on line 16 Fatal error: Uncaught Error: Call to a member function get_name() on null in /in/5cGnY:16 Stack trace: #0 {main} thrown in /in/5cGnY on line 16
Process exited with code 255.
Output for 7.3.32, 7.4.26
Fatal error: Uncaught Error: Call to a member function get_name() on null in /in/5cGnY:16 Stack trace: #0 {main} thrown in /in/5cGnY on line 16
Process exited with code 255.

preferences:
161.06 ms | 401 KiB | 176 Q