|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3699 function readdir() error
Submitted: 2000-03-02 03:15 UTC Modified: 2000-05-22 15:34 UTC
From: xutian at mail dot transfar dot com Assigned:
Status: Closed Package: Parser error
PHP Version: 3.0.14 OS: RedHat Linux 6.0
Private report: No CVE-ID: None
 [2000-03-02 03:15 UTC] xutian at mail dot transfar dot com
look at the below code:

while ($file = readdir($handle)) { 
    if ($file != "." && $file != ".." && $file !="0") { 
        echo $file."<br>";

if we have a file named 0 in dir "/home/txt/" and then we creat some other files, the files' list in html will not include files last created.
i think maybe readdir return 0 when it get file who's name equal 0.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2000-05-22 15:34 UTC] hholzgra at cvs dot php dot net
yes, "0" evaluates to false so the loop is terminated


while (""!=($file = readdir($handle))) 

instead, that will do

(bug closed until someone comes up with a filesystem 
where a filename may be all empty)
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Dec 09 09:01:27 2023 UTC