Home > Backend Development > PHP Tutorial > 请问个fopensocket的有关问题

请问个fopensocket的有关问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 12:01:59
Original
1175 people have browsed it

请教个fopensocket的问题

本帖最后由 php_aga 于 2014-07-04 15:42:52 编辑 本地WAPM环境,php.ini有打开allow_url_fopen = On
write.php
$fp = fsockopen('localhost',80,&$errno,&$errstr,5); 
if(!$fp)

echo "$errstr ($errno)
\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); <br />if(!$fp) { <br />  echo "$errstr ($errno)<br />\n"; <br />}else {<br />  fputs($fp,"GET /1.php HTTP/1.0\r\nHost: localhost\r\nConnection: Close\r\n\r\n");<br />  while (!feof($fp)) {<br />    echo fgets($fp, 128);<br />  }<br />  fclose($fp);<br />}
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template