dzimedrol
Новичок
fsockopen, fgets и лишние строки
Привет. Делаю так (чисто для примера):
<?php
$fp = fsockopen("oldi.ru", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: oldi.ru\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
Получаю ответ, но что за посторонние строки (выделено красным)?
HTTP/1.1 200 OK
Date: Tue, 22 Nov 2005 00:21:41 GMT
Server: Apache/1.3.28 (Unix) AuthMySQL/2.20
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
X-Powered-By: PHP/4.3.10
Set-Cookie: PHPSESSID=df2b0e9b805fb38e5c3222794901682d; path=/
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html
AE
<html>
<head>
<title>ОЛДИ</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<link rel="stylesheet" href="/css/style.css" type="text/css">
5AF
<script language="JavaScript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
}
...и так далее
Привет. Делаю так (чисто для примера):
<?php
$fp = fsockopen("oldi.ru", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: oldi.ru\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
Получаю ответ, но что за посторонние строки (выделено красным)?
HTTP/1.1 200 OK
Date: Tue, 22 Nov 2005 00:21:41 GMT
Server: Apache/1.3.28 (Unix) AuthMySQL/2.20
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
X-Powered-By: PHP/4.3.10
Set-Cookie: PHPSESSID=df2b0e9b805fb38e5c3222794901682d; path=/
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html
AE
<html>
<head>
<title>ОЛДИ</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<link rel="stylesheet" href="/css/style.css" type="text/css">
5AF
<script language="JavaScript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
}
...и так далее