|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35635 is_dir and is_file not working properly
Submitted: 2005-12-11 21:54 UTC Modified: 2005-12-11 22:15 UTC
From: plesek at nln dot cz Assigned:
Status: Not a bug Package: Directory function related
PHP Version: 4.4.1 OS: Windows XP Professional SP2
Private report: No CVE-ID: None
 [2005-12-11 21:54 UTC] plesek at nln dot cz
The behavior of following code is rather unpredictable. In the case of opendir("."), all works perfecty, but if you add something like /anotherdir, then you run into problems. In this example, let's assume we have dir structure ./whatever/ with another 2 folders and files. The result CAN be, as following, but it happened to me, that all dirs were recognized correctly or for example only one was. Only special dirs, . and .. are recognized. I tried several tips, that were on the internet, like ending slash, or backslashes instead of normal ones (windows), with no result. And on different folders, again the same, with minor fluctuations, as mentioned above.
And as for is_file, te result will be all false in any case, tried several times.Again, it applies only for other directories, than "."
All extensions disabled,of course.

Reproduce code:
while($element=readdir($handler)) {
echo " $element<br/>";

Expected result:
bool(true) dir1
bool(true) dir2
bool(false) file1.txt
bool(false) file2.txt

Actual result:
bool(false) dir1
bool(false) dir2
bool(false) file1.txt
bool(false) file2.txt


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-11 21:59 UTC]
Did you try to see what's in the $element?
Of course it doesn't work, you need to do it this way:

No bug here.
 [2005-12-11 22:15 UTC] plesek at nln dot cz
You're right of course, my apologies, I won't try to report bugs after 9 hours of work. 
Iteresting notice: Got my code working on linux box, rather confusing,but never mind.
Thanks anyway
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jul 18 14:01:29 2024 UTC