3v4l.org

run code in 300+ PHP versions simultaneously
<?PHP //directory to list, you choose; here we’ll just use the webroot $path = $_SERVER['DOCUMENT_ROOT']+"/filemanager/"; //warning: `is_dir` will need you to change to the parent directory of what you are testing //see <uk3.php.net/manual/en/function.is-dir.php#70005> for details chdir ($path); //get a directory listing $dir = array_diff (scandir ('.'), //folders / files to ignore array ('.DS_Store', 'Thumbs.db') ); //sort folders first, then by type, then alphabetically usort ($dir, create_function ('$a,$b', 'return is_dir ($a) ? (is_dir ($b) ? strnatcasecmp ($a, $b) : -1) : (is_dir ($b) ? 1 : ( strcasecmp (pathinfo ($a, PATHINFO_EXTENSION), pathinfo ($b, PATHINFO_EXTENSION)) == 0 ? strnatcasecmp ($a, $b) : strcasecmp (pathinfo ($a, PATHINFO_EXTENSION), pathinfo ($b, PATHINFO_EXTENSION)) )) ; ')); //echo to screen header ('content-type: text/plain'); print_r ($dir);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Uncaught TypeError: Unsupported operand types: string + string in /in/eeEeO:3 Stack trace: #0 {main} thrown in /in/eeEeO on line 3
Process exited with code 255.
Output for 7.4.33
Warning: A non-numeric value encountered in /in/eeEeO on line 3 Warning: A non-numeric value encountered in /in/eeEeO on line 3 Warning: chdir(): No such file or directory (errno 2) in /in/eeEeO on line 7 Deprecated: Function create_function() is deprecated in /in/eeEeO on line 18 Warning: Cannot modify header information - headers already sent by (output started at /in/eeEeO:3) in /in/eeEeO on line 29 Array ( [0] => . [1] => .. [2] => bin [3] => boot [4] => dev [5] => etc [6] => home [7] => in [8] => lib [9] => lib64 [10] => mnt [11] => opt [12] => proc [13] => root [14] => run [15] => sbin [16] => srv [17] => sys [18] => tmp [19] => usr [20] => var )
Output for 7.4.26 - 7.4.32
Warning: A non-numeric value encountered in /in/eeEeO on line 3 Warning: A non-numeric value encountered in /in/eeEeO on line 3 Warning: chdir(): open_basedir restriction in effect. File(0) is not within the allowed path(s): (/tmp:/in:/etc) in /in/eeEeO on line 7 Warning: scandir(): open_basedir restriction in effect. File(.) is not within the allowed path(s): (/tmp:/in:/etc) in /in/eeEeO on line 10 Warning: scandir(.): failed to open dir: Operation not permitted in /in/eeEeO on line 10 Warning: scandir(): (errno 1): Operation not permitted in /in/eeEeO on line 10 Warning: array_diff(): Expected parameter 1 to be an array, bool given in /in/eeEeO on line 12 Deprecated: Function create_function() is deprecated in /in/eeEeO on line 18 Warning: usort() expects parameter 1 to be array, null given in /in/eeEeO on line 18 Warning: Cannot modify header information - headers already sent by (output started at /in/eeEeO:3) in /in/eeEeO on line 29
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.25
Warning: A non-numeric value encountered in /in/eeEeO on line 3 Warning: A non-numeric value encountered in /in/eeEeO on line 3 Warning: chdir(): No such file or directory (errno 2) in /in/eeEeO on line 7 Warning: Cannot modify header information - headers already sent by (output started at /in/eeEeO:3) in /in/eeEeO on line 29 Array ( [0] => . [1] => .. [2] => bin [3] => boot [4] => dev [5] => etc [6] => home [7] => in [8] => lib [9] => lib64 [10] => mnt [11] => opt [12] => proc [13] => root [14] => run [15] => sbin [16] => srv [17] => sys [18] => tmp [19] => usr [20] => var )
Output for 5.2.3 - 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.40, 7.0.0 - 7.0.33
Warning: chdir(): No such file or directory (errno 2) in /in/eeEeO on line 7 Warning: Cannot modify header information - headers already sent by (output started at /in/eeEeO:7) in /in/eeEeO on line 29 Array ( [0] => . [1] => .. [2] => bin [3] => boot [4] => dev [5] => etc [6] => home [7] => in [8] => lib [9] => lib64 [10] => mnt [11] => opt [12] => proc [13] => root [14] => run [15] => sbin [16] => srv [17] => sys [18] => tmp [19] => usr [20] => var )
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.2
<br /> <b>Warning</b>: chdir() [<a href='function.chdir'>function.chdir</a>]: No such file or directory (errno 2) in <b>/in/eeEeO</b> on line <b>7</b><br /> <br /> <b>Warning</b>: scandir(.) [<a href='function.scandir'>function.scandir</a>]: failed to open dir: Permission denied in <b>/in/eeEeO</b> on line <b>10</b><br /> <br /> <b>Warning</b>: scandir() [<a href='function.scandir'>function.scandir</a>]: (errno 13): Permission denied in <b>/in/eeEeO</b> on line <b>10</b><br /> <br /> <b>Warning</b>: array_diff() [<a href='function.array-diff'>function.array-diff</a>]: Argument #1 is not an array in <b>/in/eeEeO</b> on line <b>13</b><br /> <br /> <b>Warning</b>: usort() [<a href='function.usort'>function.usort</a>]: The argument should be an array in <b>/in/eeEeO</b> on line <b>26</b><br />
Output for 4.4.5 - 4.4.9
<br /> <b>Warning</b>: chdir() [<a href='function.chdir'>function.chdir</a>]: No such file or directory (errno 2) in <b>/in/eeEeO</b> on line <b>7</b><br /> <br /> <b>Fatal error</b>: Call to undefined function: scandir() in <b>/in/eeEeO</b> on line <b>10</b><br />
Process exited with code 255.
Output for 4.4.3 - 4.4.4
<br /> <b>Warning</b>: chdir() [<a href='function.chdir'>function.chdir</a>]: No such file or directory (errno 2) in <b>/in/eeEeO</b> on line <b>7</b><br /> <br /> <b>Fatal error</b>: Call to undefined function: scandir() in <b>/in/eeEeO</b> on line <b>10</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.2
<br /> <b>Warning</b>: chdir(): No such file or directory (errno 2) in <b>/in/eeEeO</b> on line <b>7</b><br /> <br /> <b>Fatal error</b>: Call to undefined function: scandir() in <b>/in/eeEeO</b> on line <b>10</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1
<br /> <b>Warning</b>: chdir() [<a href='http://www.php.net/function.chdir'>function.chdir</a>]: No such file or directory (errno 2) in <b>/in/eeEeO</b> on line <b>7</b><br /> <br /> <b>Fatal error</b>: Call to undefined function: scandir() in <b>/in/eeEeO</b> on line <b>10</b><br />

preferences:
329.72 ms | 402 KiB | 464 Q