|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-04-04 23:48 UTC] marek at welshdragon dot com
$DH = opendir(".");
while (print(readdir($DH)));
this continues until the script times out
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 14:00:01 2025 UTC |
It is not an error under PHP to print a false value, which is all that the print() statement here would be doing once readdir() started returning false. Therefore, the loop continues. For instance, the following bit of code should never print 'Didn't print false': <?php if ( print( false ) ) { echo "Printed false<br>\n"; } else { echo "Didn't print false<br>\n"; } ?> The following should do what you want: <?php $DH = opendir("."); while ( $dir_entry = readdir( $DH ) ) { print "$dir_entry<br>\n"; } ?>