|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-07-21 16:33 UTC] jani@php.net
Description:
------------
# echo "1" > /tmp/test.txt
# php_5_2/sapi/cli/php -n -r '$fp=fopen("/tmp/test.txt", "r"); while(1) {$a=fread($fp, 8192); if (!$a) {var_dump($a); exit;}}'
string(0) ""
# php_5_3/sapi/cli/php -n -r '$fp=fopen("/tmp/test.txt", "r"); while(1) {$a=fread($fp, 8192); if (!$a) {var_dump($a); exit;}}'
string(0) ""
# php_6/sapi/cli/php -n -r '$fp=fopen("/tmp/test.txt", "r"); while(1) {$a=fread($fp, 8192); if (!$a) {var_dump($a); exit;}}'
bool(false)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 11:00:01 2025 UTC |
Confirmed in php6.0-200810110430. Cannot reliably loop through data using feof() when recognizing FALSE as an error. while ( !( feof( $handle ) ) ) { if ( ( $text = fread( $handle, 1024 ) ) === FALSE ) { // When attempting to read past the EOF, PHP 6 returns FALSE rather than an empty string die( 'Error!' ); } $data .= $text; } In PHP < 6, the above code will not display the error. In PHP 6, it does a good job of breaking a lot of code. Is this new functionality intended or are there plans to fix it?