3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Person { public string $name { get => $this->name; set => $this->name = ucfirst(trim($value)); } } class Employee extends Person { public function displayName(): string { // getName() was getter before return $this->getName(); } } $employee = new Employee(); $employee->name = 'John'; var_dump($employee->displayName());
Output for 8.4.1 - 8.4.13
Fatal error: Uncaught Error: Call to undefined method Employee::getName() in /in/HIHXs:17 Stack trace: #0 /in/HIHXs(25): Employee->displayName() #1 {main} thrown in /in/HIHXs on line 17
Process exited with code 255.
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.26
Parse error: syntax error, unexpected token "{", expecting "," or ";" in /in/HIHXs on line 5
Process exited with code 255.

preferences:
160.24 ms | 1013 KiB | 7 Q