3v4l.org

run code in 300+ PHP versions simultaneously
<?php class FooIterator extends ArrayIterator { public function current() { return 'herpderp'; } } $a = [1,2,3]; next($a); var_dump(current($a)); rewind($a); var_dump(current($a));
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Deprecated: Return type of FooIterator::current() should either be compatible with ArrayIterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/2Koi2 on line 4 int(2) Fatal error: Uncaught TypeError: rewind(): Argument #1 ($stream) must be of type resource, array given in /in/2Koi2:12 Stack trace: #0 /in/2Koi2(12): rewind(Array) #1 {main} thrown in /in/2Koi2 on line 12
Process exited with code 255.
Output for 8.0.0 - 8.0.30
int(2) Fatal error: Uncaught TypeError: rewind(): Argument #1 ($stream) must be of type resource, array given in /in/2Koi2:12 Stack trace: #0 /in/2Koi2(12): rewind(Array) #1 {main} thrown in /in/2Koi2 on line 12
Process exited with code 255.
Output for 5.4.1 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 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
int(2) Warning: rewind() expects parameter 1 to be resource, array given in /in/2Koi2 on line 12 int(2)

preferences:
218.77 ms | 403 KiB | 242 Q