How to submit a post request for a phppost request in php? I want to request a URL and pass the parameters in. It returns the results of an xml file. Post in php ., Function_xpost ($ url, $ p) {$ f = ''; $ data =''; foreach ($ pas $ k = & gt; $ v) {$ data. = php post request
In php, how do I submit a post request? I need to request a URL and input parameters. It returns the results of an xml file. Post in php.
------ Solution --------------------
Function _ xpost ($ url, $ p)
{
$ F = '';
$ Data = '';
Foreach ($ p as $ k => $ v)
{
$ Data. = $ f. $ k. '='. urlencode ($ v );
$ F = '&';
}
$ X = _ xpost ('http: // abc.com/aa.php', array ('username' => $ uname,
));
------ Solution --------------------
Use curl on the first floor
------ Solution --------------------
Use simplexml to parse xml. after learning simplexml, you don't need to worry about xml.
Discussion
For more information, see $ x = _ xpost ('http: // abc.com/aa.php', array ('username' => $ uname). the received data is an xml file:
1
How can I get Between 1?
------ Solution --------------------
A simple regex,
Preg_match ('/ (.*?) <\/Response>/S', $ xml, $ m );
Echo $ m [1];
------ Solution --------------------
Discussion
For more information, see $ x = _ xpost ('http: // abc.com/aa.php', array ('username' => $ uname). the received data is an xml file:
1
How can I get Between 1?
------ Solution --------------------
Simplexml
------ Solution --------------------
Strong regular expressions on the top 6 floors
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