|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 11:00:01 2025 UTC |
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.