note 83204 added to function.stream-get-line
| From: | mail at mdijksman dot nl | Date: | Thu, 15 May 2008 10:32:19 +0000 |
| Subject: | note 83204 added to function.stream-get-line | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-139402@lists.php.net to get a copy of this message | ||
In addition to dante at lorenso dot com:
I was having problems reading the header of a response with stream_get_line, on the Date: part.
<?php
// Sometimes took about 2 minutes
while (!feof($fp))
{
$line = stream_get_line($fp, 1024, "\n");
if (strcmp($line, "\r") == 0)
{
break;
}
}
// Always takes less than a second
while (!feof($fp))
{
$line = fgets($fp, 1024);
if (strcmp($line, "\r\n") == 0)
{
break;
}
}
?>
I could find no logic in this, as the stream_get_line sometimes went fast, and sometimes went really
slow. In the end I just stopped using stream_get_line and switched to fgets.
----
Server IP: 89.248.170.61
Probable Submitter: 86.95.230.249
----
Manual Page -- http://www.php.net/manual/en/function.stream-get-line.php
Edit -- https://master.php.net/note/edit/83204
Del: integrated -- https://master.php.net/note/delete/83204/integrated
Del: useless -- https://master.php.net/note/delete/83204/useless
Del: bad code -- https://master.php.net/note/delete/83204/bad+code
Del: spam -- https://master.php.net/note/delete/83204/spam
Del: non-english -- https://master.php.net/note/delete/83204/non-english
Del: in docs -- https://master.php.net/note/delete/83204/in+docs
Del: other reasons-- https://master.php.net/note/delete/83204
Reject -- https://master.php.net/note/reject/83204
Search -- https://master.php.net/manage/user-notes.php