3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public static function test($tableau) { var_dump($tableau); return true; } } class B extends A{ static function test($tableau) { $limit = 5; $res = true; $size = count($tableau); if( $size > $limit ) { for ($i=0; $i < round($size/$limit) ; $i++) { echo ($i*$limit); $res &= parent::test(array_splice($tableau,($i*$limit),$limit)); } } return $res; } } $ar = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o'); echo count($ar)."\n----------\n"; B::test($ar); var_dump(array_splice($ar,5,5));
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 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, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
15 ---------- 0array(5) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "e" } 5array(5) { [0]=> string(1) "k" [1]=> string(1) "l" [2]=> string(1) "m" [3]=> string(1) "n" [4]=> string(1) "o" } 10array(0) { } array(5) { [0]=> string(1) "f" [1]=> string(1) "g" [2]=> string(1) "h" [3]=> string(1) "i" [4]=> string(1) "j" }
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/Z0o7E on line 3
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/Z0o7E 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/Z0o7E on line 3
Process exited with code 255.

preferences:
242.5 ms | 401 KiB | 327 Q