3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); class TestClass { public int $a; } $test = new TestClass(); $string = 'foo'; $test->int = &$string; var_dump($test->int); $test->int = []; var_dump($test->int);
Output for 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Deprecated: Creation of dynamic property TestClass::$int is deprecated in /in/F6pnT on line 10 string(3) "foo" array(0) { }
Output for 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27
string(3) "foo" array(0) { }
Output for 7.3.0 - 7.3.33
Parse error: syntax error, unexpected 'int' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /in/F6pnT on line 5
Process exited with code 255.
Output for 4.3.0
<br /> <b>Parse error</b>: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in <b>/in/F6pnT</b> on line <b>5</b><br />
Process exited with code 255.

preferences:
131.31 ms | 401 KiB | 147 Q