3v4l.org

run code in 300+ PHP versions simultaneously
<?php readonly class User { public function __construct( public int $id, public string $name ) {} } $user = new User(123, "Rasmus"); var_dump($user->id, $user->name); $user->id = 456; // error: Cannot modify readonly property User::$id
Output for git.master_jit, git.master
int(123) string(6) "Rasmus" Fatal error: Uncaught Error: Cannot modify readonly property User::$id in /in/DiV1A:14 Stack trace: #0 {main} thrown in /in/DiV1A on line 14
Process exited with code 255.

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:
34.5 ms | 405 KiB | 5 Q