3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /** * @property stdClass $x * @property stdClass $y */ class C { private $buffer = array(); function __get($key) { if (array_key_exists($key, $this->buffer)) { return $this->buffer[$key]; } $f = 'calc_' . $key; return $this->buffer[$key] = $this->$f(); } function calc_x() { $x = new stdClass; $x->y = $this->y; return $x; } function calc_y() { $y = new stdClass; // Set a stub to avoid infinite recursion. $this->buffer['y'] = $y; $y->x = $this->x; return $y; } } $c = new C; $c->x; $c = new C; $c->y;
based on elO7m
Output for 5.3.21 - 7.0.20, 7.1.5 - 7.2.0
Notice: Undefined property: C::$x in /in/00Kuv on line 28 Notice: Undefined property: C::$y in /in/00Kuv on line 20
Output for 7.1.0
Notice: Undefined property: C::$y in /in/00Kuv on line 20