3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Orig {} class Override1 {} class Override2 {} class Override3 {} class A { function g () { global $prop, $instance; $newProp = ['override1']; $newInstance = new Override1; $prop=$newProp; $instance=$newInstance; } function ap ($prop, $instance) { $newProp = ['override2']; $newInstance = new Override2; $prop=$newProp; $instance=$newInstance; } function al (&$prop, &$instance) { $newProp = ['override3']; $newInstance = new Override3; $prop=$newProp; $instance=$newInstance; } } $prop = ['orig']; $instance = new Orig; var_dump('Orig:', $prop[0], get_class($instance), '------'); $prop = ['orig']; $instance = new Orig; (new A)->g(); var_dump('As global:', $prop[0], get_class($instance), '------'); $prop = ['orig']; $instance = new Orig; (new A)->ap($prop, $instance); var_dump('As arg:', $prop[0], get_class($instance), '------'); $prop = ['orig']; $instance = new Orig; (new A)->al($prop, $instance); var_dump('As link arg:', $prop[0], get_class($instance), '------');
Output for git.master, git.master_jit, rfc.property-hooks
string(5) "Orig:" string(4) "orig" string(4) "Orig" string(6) "------" string(10) "As global:" string(9) "override1" string(9) "Override1" string(6) "------" string(7) "As arg:" string(4) "orig" string(4) "Orig" string(6) "------" string(12) "As link arg:" string(9) "override3" string(9) "Override3" string(6) "------"

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:
24.66 ms | 402 KiB | 8 Q