note 83204 deleted from function.stream-get-line by danbrown
| From: | danbrown@php.net | Date: | Mon, 24 Jan 2011 21:28:01 +0000 |
| Subject: | note 83204 deleted from function.stream-get-line by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-176258@lists.php.net to get a copy of this message | ||
Note Submitter: mail at mdijksman dot nl
----
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.