note 87144 modified in function.fsockopen by danbrown
| From: | danbrown@php.net | Date: | Fri, 21 Nov 2008 14:40:41 +0000 |
| Subject: | note 87144 modified in function.fsockopen by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-146795@lists.php.net to get a copy of this message | ||
To just take the HTTP content from fsockopen, better wait until feof finish to read the \r\n
separator
<?php
//fsockopen, fputs..
$content = "";
$header = "not yet";
while( !feof( $pointer ) ) {
$line = fgets( $pointer, 128 );
if( $line == "\r\n" && $header == "not yet" ) {
$header = "passed";
}
if( $header == "passed" ) {
$content .= $line;
}
}
//fclose..
echo( substr( $content, 2 ) );
?>
--was--
To just take the HTTP content from fsockopen, better wait until feof finish to read the \r\n
separator
//fsockopen, fputs..
$content = "";
$header = "not yet";
while( !feof( $pointer ) ) {
$line = fgets( $pointer, 128 );
if( $line == "\r\n" && $header == "not yet" ) {
$header = "passed";
}
if( $header == "passed" ) {
$content .= $line;
}
}
//fclose..
echo( substr( $content, 2 ) );
http://php.net/manual/en/function.fsockopen.php