ID: 37910 User updated by: andy dot shellam at mailnetwork dot co dot uk Reported By: andy dot shellam at mailnetwork dot co dot uk Status: Bogus Bug Type: Directory function related Operating System: Fedora Core 5 PHP Version: 5.1.4 New Comment:
The output is coming directly from scandir, so if a / was needed, surely scandir should add it in for directories? Also is_dir doesn't actually return false, it just returns Null. Previous Comments: ------------------------------------------------------------------------ [2006-06-25 19:09:07] [EMAIL PROTECTED] You forgot to add "/" to the directory name. ------------------------------------------------------------------------ [2006-06-25 18:57:41] andy dot shellam at mailnetwork dot co dot uk Description: ------------ Running is_dir on an array of files returned from scandir, only returns TRUE on the "." and ".." directories. Actually, is_dir returns nothing on anything except "." and "..". I notice an extremely old bug #5693 had the same issue. Reproduce code: --------------- <?php function SwitchRC($code) { if ($code == 1) { return "TRUE"; } else { return "FALSE"; } } $Files = scandir("/"); for ($intC = 0; $intC < count($Files); $intC++) { echo $Files[$intC] . " = " . SwitchRC(is_dir($Files[$intC])) . "\n"; } ?> Expected result: ---------------- . = TRUE .. = TRUE .autofsck = TRUE bin = TRUE boot = TRUE dev = TRUE endeavour = TRUE etc = TRUE home = TRUE lib = TRUE lost+found = TRUE media = TRUE misc = TRUE mnt = TRUE net = TRUE opt = TRUE proc = TRUE root = TRUE sbin = TRUE selinux = TRUE srv = TRUE sys = TRUE test_text_file = FALSE tmp = TRUE usr = TRUE var = TRUE (test_text_file) is a file, everything else is a directory, as shown by the "ls -l /" output: total 168 drwxr-xr-x 2 root root 4096 Jun 22 02:20 bin drwxr-xr-x 3 root root 4096 Jun 19 19:19 boot drwxr-xr-x 9 root root 3600 Jun 22 19:17 dev drwxrwxr-x 9 root dataHandler 4096 Jun 25 01:29 endeavour drwxr-xr-x 88 root root 12288 Jun 24 16:06 etc drwxr-xr-x 7 root root 4096 Jun 21 22:39 home drwxr-xr-x 11 root root 4096 Jun 21 19:14 lib drwx------ 2 root root 16384 Jun 19 20:02 lost+found drwxr-xr-x 2 root root 4096 Feb 11 17:16 media drwxr-xr-x 2 root root 4096 Feb 11 03:06 misc drwxr-xr-x 2 root root 4096 Feb 11 17:16 mnt drwxr-xr-x 2 root root 0 Jun 22 19:17 net drwxr-xr-x 2 root root 4096 Feb 11 17:16 opt dr-xr-xr-x 91 root root 0 Jun 22 20:15 proc drwxr-x--- 13 root root 4096 Jun 20 01:43 root drwxr-xr-x 2 root root 12288 Jun 20 22:37 sbin drwxr-xr-x 3 root root 0 Jun 22 20:15 selinux drwxr-xr-x 2 root root 4096 Feb 11 17:16 srv drwxr-xr-x 11 root root 0 Jun 22 20:15 sys -rw-r--r-- 1 root root 25 Jun 25 02:47 test_text_file drwxrwxrwt 10 root root 4096 Jun 25 02:48 tmp drwxr-xr-x 14 root root 4096 Jun 19 19:14 usr drwxr-xr-x 22 root root 4096 Jun 19 19:36 var Actual result: -------------- . = TRUE .. = TRUE .autofsck = FALSE bin = FALSE boot = FALSE dev = FALSE endeavour = FALSE etc = FALSE home = FALSE lib = FALSE lost+found = FALSE media = FALSE misc = FALSE mnt = FALSE net = FALSE opt = FALSE proc = FALSE root = FALSE sbin = FALSE selinux = FALSE srv = FALSE sys = FALSE test_text_file = FALSE tmp = FALSE usr = FALSE var = FALSE ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37910&edit=1