3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { protected $_vars = array(); public function __get($var) { echo "__get called\n"; return $this->_vars[$var]; } public function __set($var, $val) { echo "__set called\n"; $this->_vars[$var] = $val; } public function __isset($var) { echo "__isset called\n"; return isset($this->_vars[$var]); } } $o = new A(); $o->a = 1; $o->b = 2; $c = $o->b = 3; var_dump($c); //3 var_dump($o->b); //3 var_dump(empty($o->b));
Output for 5.5.0 - 5.5.36, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.24, 7.4.0 - 7.4.13, 8.0.0
__set called __set called __set called int(3) __get called int(3) __isset called __get called bool(false)