3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class LazyLabel { private $string1; private $string2; function __construct(&$string1, &$string2) { $this->string1 = & $string1; $this->string2 = & $string2; } function __toString() { $return = (string)$this->string1 . (string)$this->string2; return $return; } } $a = 'foo'; $b = 'bar'; $c = new LazyLabel($a, $b); echo $c . "\n"; $b = 'baz'; echo $c;
Output for 5.2.0 - 5.6.21, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
foobar foobaz
Output for 5.0.0 - 5.1.6
Object id #1 foobaz
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/SkEe7 on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/SkEe7 on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/SkEe7 on line 3
Process exited with code 255.