|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-01-02 00:18 UTC] intro at intro dot one dot pl
Description:
------------
For example i have 4 folders in /home directory on unix platform (a,b,c,d) and php5. The script:
I have strange thing that function is_dir not always shows every dirs as it is dir. In my example script is_dir returned only "c" as dir and the rest (a,b,d) as file.
Reproduce code:
---------------
<?php
$files=scandir("/home");
foreach ($files as $file)
{
if (is_dir($file))
{
echo "dir: $file";
}
}
?>
Expected result:
----------------
dir: a dir: b dir: c dir: d
Actual result:
--------------
dir: c
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 07:00:01 2025 UTC |
Hmmmm i've done something else. Function filetype. And after use filetype on some folder i have many warnings that "Lstat failed for file". And the same way i think works "is_dir". Only a few files and folders are with no this warning and is showing as dir or file etc. The same is on other functions as is_file etc. My last code in tests: <?php $directorytoread = "/home" $files=scandir($directorytoread); $listdirindir = array(); // var_dump($files); // all files are listing which is in folder /home foreach ($files as $file) { if ( filetype($file) == "dir" ) echo "File \"$file\" is dir and "; if (is_dir($file)) { array_push($listdirindir,$file); echo "dir \"$file\" added<br/>"; } } print_r($listdirindir); ?> ...and my examples result is: many of warnings + File "." is dir and dir "." added File ".." is dir and dir ".." added + many of warnings + File "c" is dir and dir "c" added + many of warnings + Array ( [0] => . [1] => .. [2] => c )