3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = ["red", "green", "blue", "yellow"]; function getA() { return $input; }; echo array_splice(getA(), 3, 0, "purple");
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Warning: Undefined variable $input in /in/carN3 on line 6 Notice: Only variables should be passed by reference in /in/carN3 on line 9 Fatal error: Uncaught TypeError: array_splice(): Argument #1 ($array) must be of type array, null given in /in/carN3:9 Stack trace: #0 /in/carN3(9): array_splice(NULL, 3, 0, 'purple') #1 {main} thrown in /in/carN3 on line 9
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.6 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined variable: input in /in/carN3 on line 6 Notice: Only variables should be passed by reference in /in/carN3 on line 9 Warning: array_splice() expects parameter 1 to be array, null given in /in/carN3 on line 9
Output for 7.3.32 - 7.3.33
Warning: array_splice() expects parameter 1 to be array, null given in /in/carN3 on line 9
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28
Notice: Undefined variable: input in /in/carN3 on line 6 Strict Standards: Only variables should be passed by reference in /in/carN3 on line 9 Warning: array_splice() expects parameter 1 to be array, null given in /in/carN3 on line 9

preferences:
225.1 ms | 402 KiB | 299 Q