|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-08-08 10:58 UTC] felipe@php.net
[2008-08-08 13:34 UTC] stuff at axxess dot co dot za
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 06:00:01 2025 UTC |
Description: ------------ feof(bad_fd) returns FALSE, which indicates that the file descriptor has more data. This is wrong in *every* case. It should return TRUE (no more data), or throw a fatal error. More than a few sloppy fools fail to test the result of fopen(), and blow your bandwidth cap and/or hosting budget for a year by serving warnings when your RSS source changes their DNS name. Reproduce code: --------------- <?php $f = fopen ("http://dns.err/foo.html","r"); # ie. $f=FALSE while (!feof ($f)) { # ie. !feof(FALSE) $verse .= fgets($f, 4096); } fclose ($f); echo "DONE"; Expected result: ---------------- Warning: fopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/andrewm/x.php on line 2 Warning: fopen(http://dns.err/foo.html): failed to open stream: No such file or directory in /home/andrewm/x.php on line 2 Warning: feof(): supplied argument is not a valid stream resource in /home/andrewm/x.php on line 3 DONE Actual result: -------------- Warning: fopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/andrewm/x.php on line 2 Warning: fopen(http://dns.err/foo.html): failed to open stream: No such file or directory in /home/andrewm/x.php on line 2 Warning: feof(): supplied argument is not a valid stream resource in /home/andrewm/x.php on line 3 Warning: fgets(): supplied argument is not a valid stream resource in /home/andrewm/x.php on line 4 Warning: feof(): supplied argument is not a valid stream resource in /home/andrewm/x.php on line 3 Warning: fgets(): supplied argument is not a valid stream resource in /home/andrewm/x.php on line 4 Warning: feof(): supplied argument is not a valid stream resource in /home/andrewm/x.php on line 3 Warning: fgets(): supplied argument is not a valid stream resource in /home/andrewm/x.php on line 4 Warning: feof(): supplied argument is not a valid stream resource in /home/andrewm/x.php on line 3 Warning: fgets(): supplied argument is not a valid stream resource in /home/andrewm/x.php on line 4 (warnings continue ad-infinitum)