3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { protected string $city = "CityB"; private string $name = "NameA"; public function getDataA() { return [ $this->city, $this->name ]; } } class B extends A { public string $city = "CityB"; public string $name = "NameB"; public function getDataB() { return [ $this->city, $this->name ]; } } $c = new B; var_dump($c, $c->getDataA(), $c->getDataB());

preferences:
24.29 ms | 404 KiB | 5 Q