3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A{ private $__props = ["a"]; function __get($prop){ if(\array_key_exists($prop, $this->__props)){ return $this->__props[$prop]; } } function __set($prop, $value){ if($prop === "a"){ if($value > 100){ $this->__props[$prop] = $value; } else { trigger_error('Invariant "$this->a > 100" violated'); } } } } $a = new A(); $a->a = 110; $b = &$a->a; $b = "hello"; var_dump($a,$b);
Output for git.master, git.master_jit, rfc.property-hooks
Notice: Indirect modification of overloaded property A::$a has no effect in /in/ctX1c on line 22 object(A)#1 (1) { ["__props":"A":private]=> array(2) { [0]=> string(1) "a" ["a"]=> int(110) } } string(5) "hello"

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:
47.81 ms | 401 KiB | 8 Q