PHP about the File_get_contens function to the local file parameters of the problem
The source code is as follows:
$str _query = "Userid=admin&gameid=game1&serverid=server1";
$context = stream_context_create (Array (
' http ' = = Array (
' Method ' = ' POST ',
' Timeout ' = 10,
' Header ' = ' user-agent:mozilla/5.0 ' (Windows; U Windows NT 5.1; En-US) applewebkit/534.13 (khtml, like Gecko) chrome/9.0.597.98 safari/534.13\r\ncontent-type:application/ X-www-form-urlencoded\r\n ',
' Content ' = $str _query
)
));
Echo file_get_contents ("interface.php", true, $context);
?>
There are two files on the local aparche server. One is to put the above source files. One is the interface.php file.
I write the source code as above on this document. Post data to the interface.php file with file_get_contents. The result interface.php no data received.
I don't know where it went wrong. Ask Master Enlighten!!!!
Reply to discussion (solution)
Requires a protocol type
Echo file_get_contents ("http://localhost/interface.php", true, $context);
In addition to the parameter array
Header items to be written
' Header ' = ' + ' user-agent:mozilla/5.0 (Windows; U Windows NT 5.1; En-US) applewebkit/534.13 (khtml, like Gecko) chrome/9.0.597.98 safari/534.13\r\ncontent-type:application/ X-www-form-urlencoded\r\n ",
Only in double quotes \ r \ n will take effect
In addition to the parameter array
Header items to be written
' Header ' = ' + ' user-agent:mozilla/5.0 (Windows; U Windows NT 5.1; En-US) applewebkit/534.13 (khtml, like Gecko) chrome/9.0.597.98 safari/534.13\r\ncontent-type:application/x-www-......
Oh? That means there is no HTTP so it must not be!!!
This parameter is just curl get.
Reference to the 3 floor of the reply:
In addition to the parameter array
Header items to be written
' Header ' = ' + ' user-agent:mozilla/5.0 (Windows; U Windows NT 5.1; En-US) applewebkit/534.13 (khtml, like Gecko) chrome/9.0.597.98 Safari/534.13\r\ncontent-type:app ...
There is no Internet protocol, just a file system function. If you want a monkey to fly, it can't be done. The Monkey King is just using the Bodhi old man's formula to turn the somersault.
Why would file_get_contents get the full JSON content, while using curl to get an incomplete JSON content?