3v4l.org

run code in 300+ PHP versions simultaneously
<?php class User { private $username; protected $password; function __construct(){ $this->username = 'test'; } public function login() { return 'login'; } public function register() { return 'register'; } } class Teacher extends User { public $id; public $name; public $description; public $email; public $phone; function __construct(){ parent::__construct(); } public function getUsername() { return $this->username; } public function getPassword() { return $this->password; } } $o = new Teacher(); var_dump($o->getUsername());
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Warning: Undefined property: Teacher::$username in /in/I2XW1 on line 43 NULL
Output for 7.1.25 - 7.1.33, 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 property: Teacher::$username in /in/I2XW1 on line 43 NULL
Output for 7.3.32, 7.4.26
NULL

preferences:
99.66 ms | 1496 KiB | 4 Q