3v4l.org

run code in 300+ 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 git.master, git.master_jit, rfc.property-hooks
John Wick

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
88.97 ms | 405 KiB | 5 Q