note 50781 added to function.readdir
| From: | php-general at lists dot php dot net | Date: | Wed, 09 Mar 2005 21:23:25 +0000 |
| Subject: | note 50781 added to function.readdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-86176@lists.php.net to get a copy of this message | ||
Caution using this classic:
while($file = readdir($d)) { ... }
This loop will terminate in the unfortunate event that readdir encounters a file named "0"
(that's a number zero). I spent half an hour debugging this!
This is not a bug of course, since PHP evaluates "0" to FALSE. So beware.
Paul.
----
Manual Page -- http://www.php.net/manual/en/function.readdir.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50781
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50781&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50781&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50781&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50781&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50781&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50781&report=yes
Search -- http://master.php.net/manage/user-notes.php