May I ask questions about fopensocket?

Source: Internet
Author: User
Ask a question about fopensocket. This post was last edited by php_aga from 2014-07-0415: 42: 52 in the local WAPM environment, php. enable allow_url_fopen & nbsp; Onwrite. php & lt ;? Php & nbsp; $ fp & nbsp; fso ask a question about fopensocket

This post was last edited by php_aga at 15:42:52 on February 4 ,.

In the local WAPM environment, php. ini has opened 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 );
}
?>
1.php exists in the localhost root directory, but after the test runs write. php,
It is found that 1. php is not executed, and 1. php can be run separately.
Why?
I tried to change http: // localhsot/1. php to 1. php. I cannot create a link.
------ Solution --------------------
$fp = fsockopen('localhost', 80, $errno, $errstr, 5); 
if(!$fp) {
echo "$errstr ($errno)
\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);
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.