|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-10-03 09:30 UTC] ai0867 at gmail dot com
Description: ------------ --- From manual page: http://www.php.net/function.readdir#refsect1-function.readdir- returnvalues --- readdir() should return the boolean value false on failure. When calling it on a failed opendir() result (false), it returns NULL instead. http://www.php.net/manual/en/functions.internal.php This indicates that this is intentional, but the readdir() documentation says nothing about this. Test script: --------------- $dir = opendir("/tmp/this-dir-does-not-exist"); $item = readdir($dir); var_dump($item); // Should be false. Returns NULL on my machine Expected result: ---------------- false Actual result: -------------- PHP Warning: opendir(/tmp/this-dir-does-not-exist): failed to open dir: No such file or directory in /home/ai/test.php on line 2 PHP Warning: readdir() expects parameter 1 to be resource, boolean given in test.php on line 3 NULL PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 15:00:02 2025 UTC |
The error also occurs on RHEL 5.8 using PHP versions 5.3.15, 5.3.16 and 5.3.17. I was not able to test other versions. Since max_execution_time does not apply to readdir, the following code (present in Typo3) will trigger an endless loop which continues to run even after the user has aborted the HTTP request. while (($file = readdir($handle)) !== FALSE) { ... }