【发布时间】:2014-10-15 05:36:19
【问题描述】:
我对套接字编程很陌生。我看到了一些类似的代码
$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);
最后我看到它正在执行 fwrite。我的问题是它如何使用 fwrite 执行远程 php 代码。
【问题讨论】:
-
它做的事情和你的浏览器一样,一个简单的 HTTP GET 请求。它不是执行远程 PHP,而是服务器正在执行 PHP,并返回输出的 HTML/其他。