|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30981 is_dir reports a directory exists when named one thing but not another
Submitted: 2004-12-04 04:59 UTC Modified: 2004-12-06 08:27 UTC
From: andy dot thoreson at verizon dot net Assigned:
Status: Not a bug Package: Directory function related
PHP Version: 4.3.10RC1 OS: Windows 2000
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: andy dot thoreson at verizon dot net
New email:
PHP Version: OS:


 [2004-12-04 04:59 UTC] andy dot thoreson at verizon dot net
Was trying to write code that recursively scanned files in a directory tree and Apache was crashing as soon as I added the recursion...but that's another issue. In the course of debugging that, I found this one simple bug:

I run the following code (nothing else run in php file):
print "1:[".is_dir("D:\Program Files\Apache Group\Apache\htdocs\Utils\Old_Ocean_Backup")."]";
print "<br>";
print "2:[".is_dir("D:\Program Files\Apache Group\Apache\htdocs\Utils\Old_Ocean_Backup\testx")."]";
print "<br>";

The first folder always comes back as existing (returns true/1). 

The second one does not. It is just a directory I made from windows explorer (right-click, new folder).

When I rename it, in explorer, to "abc" and reload the php page (with name changed from "testx" to "abc" in code as well), is_dir says it *does* exist. Renaming to "abcx" or "testxx" etc does the same..."abcx" exists, "textxx" does not.

Renaming it back and forth from explorer reproduces the same results.

File system rights don't seem to be the issue.

Strangely, readdir does see the directory such as:
$handle=opendir("D:\Program Files\Apache Group\Apache\htdocs\Utils\Old_Ocean_Backup");
while ($file = readdir($handle)) {

Installed a fresh version of PHP and Apache today after first running into problem (was on apache 2.0 and PHP 4.3 from last week): 
PHP 4.3.10RC2-dev.
Apache 1.3
Windows NT 5.0 build 2195 (Windows 2000)

Reproduce code:
See description

Expected result:
Expected the code to treat the existance of a directory the same regardless of its name.

Actual result:
Code treats the existance of a directory different based on directory name.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-05 03:57 UTC] andy dot thoreson at verizon dot net
Did another test:
Made a directory for every letter of the alphabet and it seems as if php just doesn't like directories that start with the letters "n", "r", and "t". I tried renaming directories to various combinations and that seems to remain the case.

Reset permissions to all subdirectories of c:\aaa, security set so "everyone" has "full control".

print "a\t[".is_dir($bd."\a")."]"."<br>";
print "b\t[".is_dir($bd."\b")."]"."<br>";
print "c\t[".is_dir($bd."\c")."]"."<br>";
print "d\t[".is_dir($bd."\d")."]"."<br>";
print "e\t[".is_dir($bd."\e")."]"."<br>";
print "f\t[".is_dir($bd."\f")."]"."<br>";
print "g\t[".is_dir($bd."\g")."]"."<br>";
print "h\t[".is_dir($bd."\h")."]"."<br>";
print "i\t[".is_dir($bd."\i")."]"."<br>";
print "j\t[".is_dir($bd."\j")."]"."<br>";
print "k\t[".is_dir($bd."\k")."]"."<br>";
print "l\t[".is_dir($bd."\l")."]"."<br>";
print "m\t[".is_dir($bd."\m")."]"."<br>";
print "n\t[".is_dir($bd."\n")."]"."<br>";
print "o\t[".is_dir($bd."\o")."]"."<br>";
print "p\t[".is_dir($bd."\p")."]"."<br>";
print "q\t[".is_dir($bd."\q")."]"."<br>";
print "r\t[".is_dir($bd."\r")."]"."<br>";
print "s\t[".is_dir($bd."\s")."]"."<br>";
print "t\t[".is_dir($bd."\t")."]"."<br>";
print "u\t[".is_dir($bd."\u")."]"."<br>";
print "v\t[".is_dir($bd."\v")."]"."<br>";
print "w\t[".is_dir($bd."\w")."]"."<br>";
print "x\t[".is_dir($bd."\x")."]"."<br>";
print "y\t[".is_dir($bd."\y")."]"."<br>";
print "z\t[".is_dir($bd."\z")."]"."<br>";
This returns
1a [1]
b [1]
c [1]
d [1]
e [1]
f [1]
g [1]
h [1]
i [1]
j [1]
k [1]
l [1]
m [1]
n []
o [1]
p [1]
q [1]
r []
s [1]
t []
u [1]
v [1]
w [1]
x [1]
y [1]
z [1]
 [2004-12-06 08:27 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

Use forward slashes in your path or single quotes to quote the path string.
\r, \n and \t are special chars, that are treated as "carriage return", "new line" and "tabulation" correspondingly.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Aug 15 04:05:45 2022 UTC