3v4l.org

run code in 300+ PHP versions simultaneously
<?php $projectRoot = sys_get_temp_dir() . "/test2"; mkdir($projectRoot, 0777, true); touch("$projectRoot/file1.php"); mkdir("$projectRoot/folder", 0777, true); touch("$projectRoot/folder/evenmoar.php"); touch("$projectRoot/folder/moarcode.php"); chdir($projectRoot); $dirIterator = new RecursiveDirectoryIterator(".", FilesystemIterator::SKIP_DOTS); $iterator = new RecursiveIteratorIterator($dirIterator); foreach($iterator as $file) { echo $file; }
Output for 8.1.25 - 8.1.28, 8.2.12 - 8.2.18, 8.3.0 - 8.3.6
./file1.php./folder/evenmoar.php./folder/moarcode.php
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.4, 7.2.6 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.30, 7.4.33, 8.0.0 - 8.0.28, 8.0.30, 8.1.0 - 8.1.24, 8.2.0 - 8.2.11
./folder/moarcode.php./folder/evenmoar.php./file1.php
Output for 8.0.29
Warning: mkdir(): File exists in /in/7ADiJ on line 4 Warning: mkdir(): File exists in /in/7ADiJ on line 6 ./file1.php./folder/moarcode.php./folder/evenmoar.php
Output for 7.4.32
Warning: mkdir(): File exists in /in/7ADiJ on line 4 Warning: touch(): open_basedir restriction in effect. File(/tmp/test2/file1.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/7ADiJ on line 5 Warning: mkdir(): open_basedir restriction in effect. File(/tmp/test2/folder) is not within the allowed path(s): (/tmp:/in:/etc) in /in/7ADiJ on line 6 Warning: touch(): open_basedir restriction in effect. File(/tmp/test2/folder/evenmoar.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/7ADiJ on line 7 Warning: touch(): open_basedir restriction in effect. File(/tmp/test2/folder/moarcode.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/7ADiJ on line 8 Warning: chdir(): Not a directory (errno 20) in /in/7ADiJ on line 10 Fatal error: Uncaught UnexpectedValueException: RecursiveDirectoryIterator::__construct(): open_basedir restriction in effect. File(.) is not within the allowed path(s): (/tmp:/in:/etc) in /in/7ADiJ:11 Stack trace: #0 /in/7ADiJ(11): RecursiveDirectoryIterator->__construct('.', 4096) #1 {main} thrown in /in/7ADiJ on line 11
Process exited with code 255.
Output for 7.2.5
Warning: mkdir(): File exists in /in/7ADiJ on line 4 Warning: mkdir(): File exists in /in/7ADiJ on line 6 ./folder/moarcode.php./folder/evenmoar.php./file1.php
Output for 5.2.1 - 5.2.17
Fatal error: Class 'FilesystemIterator' not found in /in/7ADiJ on line 11
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0
Fatal error: Call to undefined function sys_get_temp_dir() in /in/7ADiJ on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected ')', expecting '(' in /in/7ADiJ on line 11
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected ')', expecting '(' in /in/7ADiJ on line 11
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'('' in /in/7ADiJ on line 11
Process exited with code 255.

preferences:
239.39 ms | 401 KiB | 371 Q