3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = range(1, 3); var_dump(current($arr)); foreach($arr as $val) { current($val); } var_dump(current($arr));
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
int(1) Fatal error: Uncaught TypeError: current(): Argument #1 ($array) must be of type array, int given in /in/5Xufe:5 Stack trace: #0 /in/5Xufe(5): current(1) #1 {main} thrown in /in/5Xufe on line 5
Process exited with code 255.
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
int(1) Warning: current() expects parameter 1 to be array, int given in /in/5Xufe on line 5 Warning: current() expects parameter 1 to be array, int given in /in/5Xufe on line 5 Warning: current() expects parameter 1 to be array, int given in /in/5Xufe on line 5 int(1)
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33
int(1) Warning: current() expects parameter 1 to be array, integer given in /in/5Xufe on line 5 Warning: current() expects parameter 1 to be array, integer given in /in/5Xufe on line 5 Warning: current() expects parameter 1 to be array, integer given in /in/5Xufe on line 5 int(1)
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
int(1) Warning: current() expects parameter 1 to be array, integer given in /in/5Xufe on line 5 Warning: current() expects parameter 1 to be array, integer given in /in/5Xufe on line 5 Warning: current() expects parameter 1 to be array, integer given in /in/5Xufe on line 5 bool(false)

preferences:
251.77 ms | 402 KiB | 327 Q