3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $myDirectory = opendir("."); // get each entry while($entryName = readdir($myDirectory)) { $dirArray[] = $entryName; } // close directory closedir($myDirectory); // count elements in array $indexCount = count($dirArray); Print ("$indexCount files<br>\n"); // sort 'em sort($dirArray); // print 'em print("<TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks>\n"); print("<TR><TH>Filename</TH><th>Filetype</th><th>Filesize</th></TR>\n"); // loop through the array of files and print them all for($index=0; $index < $indexCount; $index++) { if (substr("$dirArray[$index]", 0, 1) != "."){ // don't list hidden files print("<TR><TD><a href=\"$dirArray[$index]\">$dirArray[$index]</a></td>"); print("<td>"); print(filetype($dirArray[$index])); print("</td>"); print("<td>"); print(filesize($dirArray[$index])); print("</td>"); print("</TR>\n"); } } print("</TABLE>\n"); ?>
Output for 7.3.0rc3 - 7.3.0rc4
Warning: opendir(): open_basedir restriction in effect. File(.) is not within the allowed path(s): (/tmp:/in:/etc) in /in/XESpk on line 2 Warning: opendir(.): failed to open dir: Operation not permitted in /in/XESpk on line 2 Warning: readdir() expects parameter 1 to be resource, bool given in /in/XESpk on line 5 Warning: closedir() expects parameter 1 to be resource, bool given in /in/XESpk on line 10 Notice: Undefined variable: dirArray in /in/XESpk on line 13 Warning: count(): Parameter must be an array or an object that implements Countable in /in/XESpk on line 13 0 files<br> Warning: sort() expects parameter 1 to be array, null given in /in/XESpk on line 17 <TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks> <TR><TH>Filename</TH><th>Filetype</th><th>Filesize</th></TR> </TABLE>
Output for 7.3.0alpha1 - 7.3.0beta1
Warning: opendir(.): failed to open dir: Permission denied in /in/XESpk on line 2 Warning: readdir() expects parameter 1 to be resource, bool given in /in/XESpk on line 5 Warning: closedir() expects parameter 1 to be resource, bool given in /in/XESpk on line 10 Notice: Undefined variable: dirArray in /in/XESpk on line 13 Warning: count(): Parameter must be an array or an object that implements Countable in /in/XESpk on line 13 0 files<br> Warning: sort() expects parameter 1 to be array, null given in /in/XESpk on line 17 <TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks> <TR><TH>Filename</TH><th>Filetype</th><th>Filesize</th></TR> </TABLE>
Output for 7.2.6 - 7.2.8
Warning: opendir(): open_basedir restriction in effect. File(.) is not within the allowed path(s): (/tmp:/in) in /in/XESpk on line 2 Warning: opendir(.): failed to open dir: Operation not permitted in /in/XESpk on line 2 Warning: readdir() expects parameter 1 to be resource, boolean given in /in/XESpk on line 5 Warning: closedir() expects parameter 1 to be resource, boolean given in /in/XESpk on line 10 Notice: Undefined variable: dirArray in /in/XESpk on line 13 Warning: count(): Parameter must be an array or an object that implements Countable in /in/XESpk on line 13 0 files<br> Warning: sort() expects parameter 1 to be array, null given in /in/XESpk on line 17 <TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks> <TR><TH>Filename</TH><th>Filetype</th><th>Filesize</th></TR> </TABLE>
Output for 7.2.0
Warning: opendir(.): failed to open dir: Permission denied in /in/XESpk on line 2 Warning: readdir() expects parameter 1 to be resource, boolean given in /in/XESpk on line 5 Warning: closedir() expects parameter 1 to be resource, boolean given in /in/XESpk on line 10 Notice: Undefined variable: dirArray in /in/XESpk on line 13 Warning: count(): Parameter must be an array or an object that implements Countable in /in/XESpk on line 13 0 files<br> Warning: sort() expects parameter 1 to be array, null given in /in/XESpk on line 17 <TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks> <TR><TH>Filename</TH><th>Filetype</th><th>Filesize</th></TR> </TABLE>
Output for 7.1.20
Warning: opendir(): open_basedir restriction in effect. File(.) is not within the allowed path(s): (/tmp:/in) in /in/XESpk on line 2 Warning: opendir(.): failed to open dir: Operation not permitted in /in/XESpk on line 2 Warning: readdir() expects parameter 1 to be resource, boolean given in /in/XESpk on line 5 Warning: closedir() expects parameter 1 to be resource, boolean given in /in/XESpk on line 10 Notice: Undefined variable: dirArray in /in/XESpk on line 13 0 files<br> Warning: sort() expects parameter 1 to be array, null given in /in/XESpk on line 17 <TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks> <TR><TH>Filename</TH><th>Filetype</th><th>Filesize</th></TR> </TABLE>
Output for 5.3.0 - 7.1.10
Warning: opendir(.): failed to open dir: Permission denied in /in/XESpk on line 2 Warning: readdir() expects parameter 1 to be resource, boolean given in /in/XESpk on line 5 Warning: closedir() expects parameter 1 to be resource, boolean given in /in/XESpk on line 10 Notice: Undefined variable: dirArray in /in/XESpk on line 13 0 files<br> Warning: sort() expects parameter 1 to be array, null given in /in/XESpk on line 17 <TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks> <TR><TH>Filename</TH><th>Filetype</th><th>Filesize</th></TR> </TABLE>
Output for 5.0.4 - 5.2.17
Warning: opendir(.): failed to open dir: Permission denied in /in/XESpk on line 2 Warning: readdir(): supplied argument is not a valid Directory resource in /in/XESpk on line 5 Warning: closedir(): supplied argument is not a valid Directory resource in /in/XESpk on line 10 Notice: Undefined variable: dirArray in /in/XESpk on line 13 0 files<br> Warning: sort() expects parameter 1 to be array, null given in /in/XESpk on line 17 <TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks> <TR><TH>Filename</TH><th>Filetype</th><th>Filesize</th></TR> </TABLE>
Output for 4.3.2 - 5.0.3
Warning: opendir(.): failed to open dir: Permission denied in /in/XESpk on line 2 Warning: readdir(): supplied argument is not a valid Directory resource in /in/XESpk on line 5 Warning: closedir(): supplied argument is not a valid Directory resource in /in/XESpk on line 10 Notice: Undefined variable: dirArray in /in/XESpk on line 13 0 files<br> Warning: sort() expects parameter 1 to be array, null given in /in/XESpk on line 17 <TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks> <TR><TH>Filename</TH><th>Filetype</th><th>Filesize</th></TR> </TABLE>
Output for 4.3.0 - 4.3.1
Warning: opendir(.) [http://www.php.net/function.opendir]: failed to open dir: Permission denied in /in/XESpk on line 2 Warning: readdir(): supplied argument is not a valid Directory resource in /in/XESpk on line 5 Warning: closedir(): supplied argument is not a valid Directory resource in /in/XESpk on line 10 Notice: Undefined variable: dirArray in /in/XESpk on line 13 0 files<br> Warning: sort() expects parameter 1 to be array, null given in /in/XESpk on line 17 <TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks> <TR><TH>Filename</TH><th>Filetype</th><th>Filesize</th></TR> </TABLE>