PHP 4.0 Bug #4044 Updated: while loop continues infinitely where it should cease
| From: | Bug Database | Date: | Wed, 05 Apr 2000 04:17:08 +0000 |
| Subject: | PHP 4.0 Bug #4044 Updated: while loop continues infinitely where it should cease | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-17628@lists.php.net to get a copy of this message | ||
ID: 4044
Updated by: torben
Reported By: marek@welshdragon.com
Status: Closed
Bug Type: Other
Assigned To:
Comments:
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";
}
?>
Full Bug description available at: http://bugs.php.net/?id=4044