<?php
$fp = fsockopen("www.example.com", 80, &$errno, &$errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: www.example.com\r\n";
$out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
1 &$errno中的&的作用
2 为什么要写入 GET / HTTP/1.1\r\n Host: www.example.com\r\n Connection: Close\r\n\r\n
用fopen打开网页也不用写入东西啊,什么作用?
3 打开页面上面的东西是什么
$fp = fsockopen("www.example.com", 80, &$errno, &$errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: www.example.com\r\n";
$out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
1 &$errno中的&的作用
2 为什么要写入 GET / HTTP/1.1\r\n Host: www.example.com\r\n Connection: Close\r\n\r\n
用fopen打开网页也不用写入东西啊,什么作用?
3 打开页面上面的东西是什么
http://cn.php.net/manual/en/function.fsockopen.php
http://www.whnewnet.com/php/function.php-fsockopen.htm
2 为什么要写入 GET / HTTP/1.1\r\n Host: www.example.com\r\n Connection: Close\r\n\r\n
是HTTP头信息
3 打开页面上面的东西是什么
www.example.com只是举例,改成你要打开的网页
$arr = array(1, 2, 3, 4);
foreach ($arr as &$value) {
$value = $value * 2;
}
// $arr is now array(2, 4, 6, 8)
?>