|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15464 readdir function bug with 0 name directory
Submitted: 2002-02-09 07:58 UTC Modified: 2002-02-10 13:48 UTC
From: laurent dot colson at freesbee dot fr Assigned:
Status: Not a bug Package: *Directory/Filesystem functions
PHP Version: 4.1.0 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: laurent dot colson at freesbee dot fr
New email:
PHP Version: OS:


 [2002-02-09 07:58 UTC] laurent dot colson at freesbee dot fr
Their is a bug when using readdir function with a directory 
named 0 is in the list.
Exemple :
Directory /home/www/perso

/home/www/perso/0 * 0 is a directory
/home/www/perso/1 * 1 is a directory
/home/www/perso/2 * 2 is a directory

The code :

		echo "$fichier\n";

should be return :

however, it return only :

Cause of there is a directory named 0 in the structure.



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-10 06:04 UTC]
Reproduced. There is something really strange going on...
Anyway, create a file or directory 0 and a couple of other (both numeric and non-numeric) files and/or directories.

Sometimes it doesn't display any file starting with a number if there's a file called 0. The 0 never shows up.

(tested with a recent 4.2.0-dev)
 [2002-02-10 12:23 UTC]
The problem is that the function is returning string "0" which gets converted to FALSE which breaks out of the loop.  I don't see an easy way to fix this...
 [2002-02-10 12:29 UTC]
while(($fichier=readdir($ptr)) !== false)

 [2002-02-10 12:48 UTC] laurent dot colson at freesbee dot fr
Yes, it works with :
while(($fichier=readdir($ptr)) !== false)

In fact, sorry, it's not really a bug, another thing which 
works than I tryed :


This works with the do structure because there is always 2 
minimum derectories which are . and ..

But your solution is better, thank you very much
 [2002-02-10 12:50 UTC]
 [2002-02-10 13:48 UTC]
FWIW, I've explicitly stated this in the readdir() docs in
cvs now. Should show up in the online manual within a few 

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Mar 04 12:01:27 2024 UTC