Local WAPM environment, php.ini has open 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 under the localhost root directory, but after the test runs write.php,
Found that the 1.php was not executed, the individual execution of 1.php is can be run
May I ask why?
Try to change the http://localhsot/1.php to 1.php; no prompts to create a set of links during the process
Reply to discussion (solution)
$fp = Fsockopen (' localhost ', $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, +); } Fclose ($FP);}
$fp = Fsockopen (' localhost ', $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, +); } Fclose ($FP);}
In the local test, the other computer access to my computer, with IP can be normal execution, that is to say I test IP 192.168.10.60,
Other computers using http://192.168.10.60/write.php can be normal;
But put the program on the server, the server IP is assumed to be 192.168.10.3,
Run but cannot execute, need to put
The connection mode becomes 192.168.10.3, then fputs, to write the absolute path can be ... What's the situation?
Isn't that normal?
You put it in 192.168.10.3.
is not localhost, of course, to use absolute IP access, what is the problem?
Isn't that normal?
Two points are not normal.
1, with my machine for testing the host, other machines to access my machine, in the use of localhost can be normal operation, and put the program to the server, I do not access the server computer;
2, I say the absolute path is not to refer to Fsocketopen to create a link when writing, but for example, when the program is placed in the Web directory under the Ca/ma directory, the following
Fwrite path to write 192.168.10.3/ca/ma/1.php, even if my write program and 1.php program is placed in the same directory also need this.
But the same phenomenon I put on the local, with other computers to access the local but normal. The local is the win system, the server is the Linux system, but the path is because of the OS relationship?
1, the program is running on your machine, so with localhost can access to is normal, with your machine's IP can access to is also normal
2, when the program moved to the server, supposedly with localhost can also be accessed, but because the particularity of the server may not do 127.0.0.1 to localhost mapping, then access is not.