ID: 39433 User updated by: michael dot virnstein at brodos dot de Reported By: michael dot virnstein at brodos dot de Status: Bogus Bug Type: Streams related PHP Version: 4.4.4 New Comment:
Ok, but it didn't seem to work that way in PHP 4.2.x. I moved a script from a server with 4.2.1 to one with PHP 5.1.6 and the script stopped working. Previous Comments: ------------------------------------------------------------------------ [2006-11-08 17:52:20] [EMAIL PROTECTED] http://php.net/fgets Returns a string of up to length - 1 bytes read from the file pointed to by handle. It works this way since ages. ------------------------------------------------------------------------ [2006-11-08 17:26:24] michael dot virnstein at brodos dot de 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39433&edit=1