3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function __construct($arg1, $arg2, $arg3) { /* Do stuff constructor with arguments */ $this->arg1 = $arg1; $this->arg2 = $arg2; $this->arg3 = $arg3; } } class Bar extends Foo { public function __construct(...$args) { /** * Before argument unpacking in 5.6 we would use * call_user_func_array + func_get_args to accomplish * the same thing. */ // The intent here is to call the parent constructor parent::__construct(...$args); // Looks much nicer in 5.6 } } $bar = new Bar(1,2,3); var_dump($bar);
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Deprecated: Creation of dynamic property Bar::$arg1 is deprecated in /in/X3hlC on line 6 Deprecated: Creation of dynamic property Bar::$arg2 is deprecated in /in/X3hlC on line 7 Deprecated: Creation of dynamic property Bar::$arg3 is deprecated in /in/X3hlC on line 8 object(Bar)#1 (3) { ["arg1"]=> int(1) ["arg2"]=> int(2) ["arg3"]=> int(3) }
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
object(Bar)#1 (3) { ["arg1"]=> int(1) ["arg2"]=> int(2) ["arg3"]=> int(3) }
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38
Parse error: syntax error, unexpected '.', expecting '&' or variable (T_VARIABLE) in /in/X3hlC on line 13
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '.', expecting '&' or T_VARIABLE in /in/X3hlC on line 13
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected '.', expecting '&' or T_VARIABLE in /in/X3hlC on line 13
Process exited with code 255.
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/X3hlC on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/X3hlC on line 4
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/X3hlC on line 4
Process exited with code 255.

preferences:
261.04 ms | 401 KiB | 460 Q