|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-06-13 07:14 UTC] php at webfreezer dot com
Description:
------------
Hi,
this bug has been described before however everyone seemed to make a mistake in the report.
Create this directory/file structure in the root of drive C:
- testDir
-- Directory01
-- Directory02
-- Directory03
-- file01.txt
-- file02.txt
-- file03.txt
Then start the script below.
The BUG occurs when using a non-relative directory, i.e. an ABSOULTE path.
The documentation states "Returns TRUE if the filename exists and is a directory. If filename is a relative filename, it will be checked relative to the current working directory."
It seems that a check is only performed in the current directory. If you uncomment the chdir line everything works fine!
Please fix this reproducible bug!
(Apache 1.3.27, PHP 4.3.2)
Reproduce code:
---------------
$baseDir="c:/testDir";
function parseDir($baseDir)
{
$handle=@opendir($baseDir);
if($handle)
{
while ($file = readdir ($handle))
{
if (is_dir($file))
{
echo $file." is a directory!<br>";
} else {
echo $file." is NOT a directory!<br>";
}
}
@closedir($handle);
}
}
//chdir("c:/testDir");
parseDir("c:/testDir");
Expected result:
----------------
. is a directory!
.. is a directory!
Directory01 is a directory!
Directory02 is a directory!
Directory03 is a directory!
file01.txt is NOT a directory!
file02.txt is NOT a directory!
file03.txt is NOT a directory!
Actual result:
--------------
. is a directory!
.. is a directory!
Directory01 is NOT a directory!
Directory02 is NOT a directory!
Directory03 is NOT a directory!
file01.txt is NOT a directory!
file02.txt is NOT a directory!
file03.txt is NOT a directory!
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 21:00:01 2025 UTC |
while ($file = readdir ($handle)) { if (is_dir($file)) This looks bogus... shouldn't you be testing: is_dir($baseDir . DIRECTORY_SEPARATOR . $file) instead?