3v4l.org

run code in 300+ PHP versions simultaneously
<?php class TestCache { $vars = array(); function assign ($var, $value) { $this->vars[$var] = $value; } function fetch ($var) { return $this->vars[$var]; } } $a = new stdClass; $a->x = 3; $cache = new TestCache(); $cache->assign('a', $a); $a->x = $a->x + 1; $cachedObject = $cache->fetch('a'); if ($cachedObject->x == $a->x) { print 'By reference'; } else { print 'By value'; }
Output for 5.4.0 - 5.4.22
Parse error: syntax error, unexpected '$vars' (T_VARIABLE), expecting function (T_FUNCTION) in /in/C07ku on line 3
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /in/C07ku on line 3
Process exited with code 255.

preferences:
188.94 ms | 940 KiB | 59 Q