|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-12-08 20:25 UTC] felipe@php.net
[2007-12-10 14:19 UTC] iliaa@php.net
[2007-12-10 14:40 UTC] tylera at iproduction dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 09 04:00:01 2025 UTC |
Description: ------------ Calling stream_get_line may eat additional characters when reading a long line. If the delimiter is not encountered, a number of additional characters are removed from the stream and are not returned with the next call to stream_get_line. For some unknown reason, adding \r to the delimiter makes it work just fine. Reproduce code: --------------- <?PHP // 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ $fp = fopen('test.php', 'r'); // Open myself DoTest($fp, 'ZZZ'); // Removes 3 characters DoTest($fp, "\r"); // Doesn't break with \r for some reason function DoTest($fp, $delim) { echo "Delim: " . urlencode($delim) . "\n"; rewind($fp); echo " " . stream_get_line($fp, 10, $delim) . "\n"; echo " " . stream_get_line($fp, 10, $delim) . "\n"; } Expected result: ---------------- Delim: ZZZ <?PHP // 1 234567890A Delim: %0D <?PHP // 1 234567890A Actual result: -------------- Delim: ZZZ <?PHP // 1 567890ABCD Delim: %0D <?PHP // 1 234567890A