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);

preferences:
49.73 ms | 402 KiB | 5 Q