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();
based on gNIg4
Output for 8.0.0alpha1 - alpha2
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.31, 7.3.0 - 7.3.19, 7.4.0 - 7.4.7
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.