3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class User { public $username; public function __construct(string $username) { $this->username = $username; } } $users = [ new User('user 1'), new User('user 2'), new User('user 3'), ]; print_r(array_column($users, 'username'));
Output for hhvm-3.17.3 - 3.22.0, 7.0.0 - 7.3.0beta1
Array ( [0] => user 1 [1] => user 2 [2] => user 3 )
Output for hhvm-3.11.1 - 3.15.4
Array ( )
Output for hhvm-3.10.1
Catchable fatal error: Argument 1 passed to User::__construct() must be an instance of string, string given in /in/YG4rM on line 10
Process exited with code 255.
Output for 5.4.0 - 5.6.30
Catchable fatal error: Argument 1 passed to User::__construct() must be an instance of string, string given, called in /in/YG4rM on line 14 and defined in /in/YG4rM on line 7
Process exited with code 255.
Output for 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/YG4rM on line 13
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/YG4rM 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/YG4rM on line 5
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/YG4rM on line 5
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/YG4rM on line 5
Process exited with code 255.