PHP 4.0 Bug #5867: traversing directory is somewhat tricky
| From: | pasha at zend dot com | Date: | Mon, 31 Jul 2000 09:46:40 +0000 |
| Subject: | PHP 4.0 Bug #5867: traversing directory is somewhat tricky | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-27010@lists.php.net to get a copy of this message | ||
From: pasha@zend.com
Operating system: not relevant
PHP version: 4.0 Latest CVS (31/07/2000)
PHP Bug Type: Misbehaving function
Bug description: traversing directory is somewhat tricky
this the classical example (from the maual) how to traverse files in the directory:
$d = opendir ('.');
while ($file = readdir($d))
{
print ("$file\n");
}
closedir ($d);
unfortunately this is wrong. if the directory contains file named '0', the
"while" condition evaluates to false and the loop stops.
the ugly workaround is to use something like
while (! is_bool ($file = readdir ($d))
but of course I would prefer to be able to use the clear former syntax. My overall impression that
the notion of what is true and what is false in the current php is somewhat broken.