php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21921 opendir / readdir bug anytime
Submitted: 2003-01-28 09:09 UTC Modified: 2003-01-28 09:33 UTC
From: emmanuel dot leleu at delta-development dot fr Assigned:
Status: Not a bug Package: *Directory/Filesystem functions
PHP Version: 4.2.0 OS: ALL
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: emmanuel dot leleu at delta-development dot fr
New email:
PHP Version: OS:

 

 [2003-01-28 09:09 UTC] emmanuel dot leleu at delta-development dot fr
PHP : all version
System : all system
--------------------
i find a "little problem" !
create a dir "testmanu"
inside create another dir named "titi" and another dir named "0" (zero)
( testmanu / titi , 0 )
and try to use opendir and readdir (recursif) for find inside any dir/file =bug ! Why ? because a dir is named "0" ! 

look and try :

<?php

// Emmanuel LELEU - emmanuel.leleu@delta-development.fr / manu@cyklades.com
// EL - fReadRecursif - v1.0 - 28/01/2003 16:02
function fReadRecursif($sPath)
{
	Global $sChemin;


	if (!$pListe = @opendir($sChemin.$sPath))
	echo "<br>fReadRecursif - chemin introuvable : $sPath";
	
	echo "<br>path in progress : ".$sChemin.$sPath;

	while ($sDir = @readdir($pListe))
	{
		echo "<br>found : ".$sDir;
		if ($sDir!= "." && $sDir != "..")
		{

			if (is_dir($sChemin.$sPath."/".$sDir))
			{
				
				fReadRecursif($sPath."/".$sDir);
			}		
		}
	}
	@closedir($pListe);
}

$sChemin = "./";
fReadRecursif("testmanu");
?>

manu

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-28 09:33 UTC] wez@php.net
Please read the manual for readdir() which explains how to deal with this.
http://php.net/readdir
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 14:01:37 2025 UTC