PHP: file_get_contens function to pass parameters to local files. PHP: file_get_contens function to pass parameters to local files source code: & lt ;? Php $ str_query & quot; userIdadmin & amp; gameIdgame1 & amp; serverIdserver1 & quot; $ contextstream_cont PHP about the parameter passing from the file_get_contens function to a local file
PHP's question about passing parameters to a local file by the file_get_contens function
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 code. One is the interface. php file.
I will write the above source code on this file. Use file_get_contents to POST data to the interface. php file. Result: No data is received by interface. php.
I don't know where the error occurred. Please enlighten me !!!!
------ Solution --------------------
This parameter is just curl get.
------ Solution --------------------
Discussion
Reference:
In addition
The header must 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 ......