3v4l.org

run code in 300+ PHP versions simultaneously
<?php function odd($var) { // retourne lorsque l'entrée est impaire return($var & 1); } function even($var) { // retourne lorsque l'entrée est paire return(!($var & 1)); } $array1 = array( 0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'); echo "Impair :\n"; print_r(array_filter($array1, "odd")); //echo "Pair :\n"; //print_r(array_filter($array2, "even"));
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Impair : Fatal error: Uncaught TypeError: Unsupported operand types: string & int in /in/JigGm:6 Stack trace: #0 [internal function]: odd('a') #1 /in/JigGm(21): array_filter(Array, 'odd') #2 {main} thrown in /in/JigGm on line 6
Process exited with code 255.
Output for 7.1.0 - 7.1.33, 7.2.5 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Impair : Warning: A non-numeric value encountered in /in/JigGm on line 6 Warning: A non-numeric value encountered in /in/JigGm on line 6 Warning: A non-numeric value encountered in /in/JigGm on line 6 Warning: A non-numeric value encountered in /in/JigGm on line 6 Array ( )
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.1 - 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
Impair : Array ( )
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/JigGm on line 23
Process exited with code 255.

preferences:
235 ms | 401 KiB | 342 Q