3v4l.org

run code in 500+ PHP versions simultaneously
<?php class U { public private(set) string $name = "orig"; } $u = new U; foreach ($u as &$v) { $v = "X"; } // no error, $u->name is now "X" var_dump($u->name); $r = &$u->name; // Error: Cannot indirectly modify private(set) property
Output for master
string(1) "X" Fatal error: Uncaught Error: Cannot indirectly modify private(set) property U::$name from global scope in /in/oL4rA:7 Stack trace: #0 {main} thrown in /in/oL4rA on line 7
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:
11.94 ms | 1179 KiB | 7 Q