|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25846 is_dir() does not work on any folder other than the current directory
Submitted: 2003-10-12 18:49 UTC Modified: 2003-10-12 20:55 UTC
From: notepad at codewalkers dot com Assigned:
Status: Not a bug Package: Directory function related
PHP Version: 4.3.4RC1 OS: winXP
Private report: No CVE-ID: None
 [2003-10-12 18:49 UTC] notepad at codewalkers dot com
say you have the folder "test" and inside "test" you have:
- images (folder)
- the_following_code.php (file)

inside the "images" folder you have some sub directories. the_following_code will NEVER return true.

if i use !is_dir instead, it then returns the sub directories as files instead of folders. this appears to have been an ongoing problem, perhaps overlooked or under-explained.

Reproduce code:
function directory($dir)
    $mydir = opendir($dir);
    while(false !== ($file = readdir($mydir)))
        if($file != "." && $file != "..")
                echo "$file<br>\r\n";
                echo "$file<br>\r\n";
                echo "$file<br>\r\n";
$path = '/inetpub/wwwroot/Scripts/test/images/';

Expected result:
i expect a list of sub dirs..

Actual result:
i get nothing.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-12 19:47 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

readdir() returns only the basename of the filenames, not the full path. You need to manually concatentate the directory name to the filename.
 [2003-10-12 19:57 UTC] notepad at codewalkers dot com
the code above DOES concatentate the directory name to the filename
 [2003-10-12 20:38 UTC]
No you don't, you're appending a resource, 

resource opendir ( string path)

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 15 00:01:28 2024 UTC