3v4l.org

run code in 500+ PHP versions simultaneously
<?php class User { public string $first_name; public string $last_name; /** * this is going to be a lazy property, uninitialized by default, perhaps writting like: * * lazy public string $full_name; */ public string $full_name; function __construct() { // this is what the "lazy" type would do in the background.. keep the public property uninitialized until set otherwise handled by __get/__set unset($this->full_name); } function __get($key) { if ($key === 'full_name') { return $this->first_name.' '.$this->last_name; } } } $user = new User(); $user->first_name = 'John'; $user->last_name = 'Wick'; echo $user->full_name;
Output for 8.1.23 - 8.1.34, 8.2.7 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
John Wick

preferences:
70.85 ms | 846 KiB | 4 Q