本地WAPM环境,php.ini有打开allow_url_fopen = On
write.php
<?php
$fp = fsockopen('localhost',80,&$errno,&$errstr,5);
if(!$fp)
{
echo "$errstr ($errno)<br />\n";
}
else
{
fputs($fp,"GET / HTTP/1.0\nHost: http://localhost/1.php");
fclose($fp);
}
?>
在localhost根目录下存在1.php,但测试运行write.php后,
发现1.php并没有被执行,单独执行1.php是可以运行
请问为什么?
试过把http://localhsot/1.php改为1.php也不行;过程中没提示无法创建套链接
------解决方案--------------------
$fp = fsockopen('localhost', 80, $errno, $errstr, 5);
if(!$fp) {
echo "$errstr ($errno)<br />\n";
}else {
fputs($fp,"GET /1.php HTTP/1.0\r\nHost: localhost\r\nConnection: Close\r\n\r\n");
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}