3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class A { static function cast(&$val, $key) { if (is_numeric($val)) { $val += 0; } } static function run() { $arr = ['stri33ng123', 84, 076.7, '.6', '67.5e45', '56,9', '098']; var_dump($arr); //array_walk($arr , ['self', 'cast']); array_walk($arr , 'self::cast'); var_dump($arr); } } A::run();
Output for 5.4.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(7) { [0]=> string(11) "stri33ng123" [1]=> int(84) [2]=> float(76.7) [3]=> string(2) ".6" [4]=> string(7) "67.5e45" [5]=> string(4) "56,9" [6]=> string(3) "098" } array(7) { [0]=> string(11) "stri33ng123" [1]=> int(84) [2]=> float(76.7) [3]=> float(0.6) [4]=> float(6.75E+46) [5]=> string(4) "56,9" [6]=> int(98) }
Output for 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/f9ADI on line 11
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/f9ADI on line 11
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STATIC, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/f9ADI 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_STATIC, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/f9ADI 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/f9ADI on line 3
Process exited with code 255.