3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[AllowDynamicProperties] class Scratch_1 { } $new = new Scratch_1(); $prop = 'Content-Type'; $new->$prop = 'application/json'; var_dump($new->$prop); // string(16) "application/json" var_dump($new->{'Content-Type'}); $$prop = 'application/json'; var_dump($$prop); // string(16) "application/json" $prop = '10xl'; $new->$prop = '10xl'; var_dump($new->$prop); // string(3) "10xl" var_dump($new); var_dump(get_defined_vars()['Content-Type']); var_dump(${"Content-Type"});
Output for git.master_jit, git.master, rfc.property-hooks
string(16) "application/json" string(16) "application/json" string(16) "application/json" string(4) "10xl" object(Scratch_1)#1 (2) { ["Content-Type"]=> string(16) "application/json" ["10xl"]=> string(4) "10xl" } string(16) "application/json" string(16) "application/json"

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:
28.52 ms | 406 KiB | 5 Q