php.net |  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
15 + 4 = ?
Subscribe to this entry?

 
 [2005-12-11 21:54 UTC] plesek at nln dot cz
Description:
------------
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:
---------------
$handler=opendir("./whatever");
while($element=readdir($handler)) {
$tmp=is_dir($element);
var_dump($tmp);
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-11 21:59 UTC] tony2001@php.net
Did you try to see what's in the $element?
Of course it doesn't work, you need to do it this way:
is_dir("./whatever/".$element);

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: Tue Mar 19 08:01:29 2024 UTC