3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Interfaze { public function hello($name); public function getName(); } class ParentClazz implements Interfaze { public function __construct($name) { $this->hello($name); } public function hello($name) { echo "Hello, $name!\n"; $this->name = $name; } public function getName() { return $this->name; } } class ChildClazz extends ParentClazz { public function __construct($name) { echo "Loaded from the child class.\n"; parent::__construct($name); } } $childclass = new ChildClazz("Payton"); echo $childclass->getName() . "\n";
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Loaded from the child class. Hello, Payton! Deprecated: Creation of dynamic property ChildClazz::$name is deprecated in /in/n1Wbo on line 17 Payton
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
Loaded from the child class. Hello, Payton! Payton

preferences:
290.52 ms | 404 KiB | 376 Q