|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-11-08 17:52 UTC] tony2001@php.net
[2006-11-09 14:22 UTC] michael dot virnstein at brodos dot de
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 23:00:02 2025 UTC |
Description: ------------ i recognized a change to fgets function, which i think is a bug. When i try to fetch data from a file handle via fgets, which has been opened via fopen for a local file or url, the lenght parameter now has to be supplied as length+1 to get the desired result. E.g. fgets($fp, 1) returns false now, fgets($fp, 2) returns the first letter, fgets($fp, 3) returns the first two letters ... This bug is present in 4.4.4 and 5.1.x, couldn't test 5.2 yet. Reproduce code: --------------- <?php $fp = fopen('http://www.php.net', 'r') or die ('could not connect'); var_dump(fgets($fp, 1)); // returns false var_dump(fgets($fp, 2)); // returns first letter fclose($fp); ?> Expected result: ---------------- - first var_dump should return first letter - second var_dump should return next two letter Actual result: -------------- - first var_dump returns false - second var_dump returns first letter