3v4l.org

run code in 300+ PHP versions simultaneously
<?php //$f = new SplFileObject('/home/a.txt', "w+"); $iterator = new DirectoryIterator('/'); while($iterator->valid()) { $file = $iterator->current(); echo $iterator->key() . " => " . $file->getFilename() . "\n"; $iterator->next(); }
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.32, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught UnexpectedValueException: DirectoryIterator::__construct(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/tmp:/in:/etc) in /in/8uvhI:3 Stack trace: #0 /in/8uvhI(3): DirectoryIterator->__construct('/') #1 {main} thrown in /in/8uvhI on line 3
Process exited with code 255.
Output for 7.3.32 - 7.3.33, 7.4.26, 7.4.33, 8.0.13
0 => . 1 => .. 2 => var 3 => dev 4 => run 5 => etc 6 => tmp 7 => sys 8 => proc 9 => usr 10 => bin 11 => boot 12 => home 13 => lib 14 => lib64 15 => mnt 16 => opt 17 => root 18 => sbin 19 => srv 20 => in
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Fatal error: Uncaught exception 'UnexpectedValueException' with message 'DirectoryIterator::__construct(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (/tmp:/in:/etc)' in /in/8uvhI:3 Stack trace: #0 /in/8uvhI(3): DirectoryIterator->__construct('/') #1 {main} thrown in /in/8uvhI on line 3
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45
0 => . 1 => .. 2 => bin 3 => lib 4 => lib64 5 => sbin 6 => boot 7 => dev 8 => etc 9 => home 10 => in 11 => mnt 12 => opt 13 => proc 14 => root 15 => run 16 => srv 17 => sys 18 => tmp 19 => usr 20 => var
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Fatal error: Uncaught exception 'RuntimeException' with message 'DirectoryIterator::__construct(/): failed to open dir: Permission denied' in /in/8uvhI:3 Stack trace: #0 /in/8uvhI(3): DirectoryIterator->__construct('/') #1 {main} thrown in /in/8uvhI on line 3
Process exited with code 255.
Output for 5.0.3 - 5.0.5
Fatal error: Uncaught exception 'Exception' with message 'DirectoryIterator::__construct(/): failed to open dir: Permission denied' in /in/8uvhI:3 Stack trace: #0 /in/8uvhI(3): DirectoryIterator->__construct('/') #1 {main} thrown in /in/8uvhI on line 3
Process exited with code 255.
Output for 5.0.0 - 5.0.2
Fatal error: Uncaught exception 'Exception' with message 'DirectoryIterator::__construct(/): failed to open dir: Permission denied' in /in/8uvhI:3 Stack trace: #0 {main} thrown in /in/8uvhI on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Fatal error: Cannot instantiate non-existent class: directoryiterator in /in/8uvhI on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: directoryiterator in /in/8uvhI on line 3

preferences:
285.22 ms | 401 KiB | 460 Q