PHP questions about passing parameters to a local file using the file_get_contens function
Source: Internet
Author: User
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; userId = admin & amp; gameId = game1 & amp; serverId = ser 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
)
));
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 ......
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