3v4l.org

run code in 300+ PHP versions simultaneously
<?php //$f = new SplFileObject('/home/a.txt', "w+"); $iterator = new DirectoryIterator('/var'); while($iterator->valid()) { $file = $iterator->current(); echo $iterator->key() . " => " . $file->getFilename() . "\n"; $iterator->next(); }
Output for 7.1.26 - 7.1.33, 7.2.17 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 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(/var) is not within the allowed path(s): (/tmp:/in:/etc) in /in/rirSp:3 Stack trace: #0 /in/rirSp(3): DirectoryIterator->__construct('/var') #1 {main} thrown in /in/rirSp on line 3
Process exited with code 255.
Output for 7.3.32 - 7.3.33, 7.4.33, 8.0.13
0 => . 1 => .. 2 => cache 3 => lib 4 => log 5 => empty 6 => games 7 => local 8 => lock 9 => mail 10 => opt 11 => run 12 => spool 13 => tmp
Output for 7.1.20, 7.2.6
Fatal error: Uncaught UnexpectedValueException: DirectoryIterator::__construct(): open_basedir restriction in effect. File(/var) is not within the allowed path(s): (/tmp:/in) in /in/rirSp:3 Stack trace: #0 /in/rirSp(3): DirectoryIterator->__construct('/var') #1 {main} thrown in /in/rirSp on line 3
Process exited with code 255.
Output for 7.2.0
Fatal error: Uncaught UnexpectedValueException: DirectoryIterator::__construct(/var): failed to open dir: Permission denied in /in/rirSp:3 Stack trace: #0 /in/rirSp(3): DirectoryIterator->__construct('/var') #1 {main} thrown in /in/rirSp on line 3
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.25, 7.0.0 - 7.0.10, 7.0.20, 7.1.5 - 7.1.10
0 => . 1 => .. 2 => lock 3 => mail 4 => run 5 => cache 6 => db 7 => empty 8 => games 9 => lib 10 => local 11 => log 12 => opt 13 => spool 14 => tmp
Output for 5.6.28, 7.0.14, 7.1.0
0 => . 1 => .. 2 => cache 3 => db 4 => empty 5 => games 6 => lib 7 => local 8 => log 9 => opt 10 => spool 11 => tmp 12 => mail 13 => lock 14 => run
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Fatal error: Cannot instantiate non-existent class: directoryiterator in /in/rirSp 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/rirSp on line 3

preferences:
240.19 ms | 401 KiB | 385 Q