|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7396 is_dir() doesn't work
Submitted: 2000-10-22 19:12 UTC Modified: 2000-10-28 08:21 UTC
From: whit at transpect dot com Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4.0.3pl1 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: whit at transpect dot com
New email:
PHP Version: OS:


 [2000-10-22 19:12 UTC] whit at transpect dot com
This snippet works:

while ($file = readdir($handle)) {
        $retval[count($retval)] = $file; 
echo "CNT: $cnt";
while($int<$cnt) {
        if(!is_dir($retval[$int])) {
                echo "File: $retval[$int]<br>";
        } else {  
                echo "Dir: $retval[$int]<br>";

But if I change "if(!is_dir($retval[$int])) {" to "if(is_file($retval[$int])) {" it fails.

The way it fails is that all of the files fail to match as files, and are shown prefixed by "Dir:".


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2000-10-23 03:49 UTC]
I could not reproduce the bug with a modified code, main difference is that I am using the full path in the is_file() function, as it should be. Code below works on PHP 4.0.3pl1 (RedHat 6.1 and Solaris 2.6):

$dir ="/path/to/phpdoc/en";
while ($file = readdir($handle)) {
    $retval[count($retval)] = $dir."/".$file; 
echo "CNT: $cnt\n";
while($int<$cnt) {
  if(is_file($retval[$int])) {
          echo "File: ".$retval[$int]."\n";
  } else {  
          echo "Dir: ".$retval[$int]."\n";

 [2000-10-27 08:12 UTC]
Please check the example Jesus gave. And report back whether it 
solves this or not.

 [2000-10-28 08:21 UTC]
I received an e-mail fromn to the effect that the code changes I made fixed the problem he had.

Closing this bug report now.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Feb 26 20:01:28 2024 UTC