在php里面怎么提交一个post请求,我要请求一个网址,传参数进去。他会返回一个xml格式的文件结果。在php里面怎么post。
解决方案 »
- 如何用php给另一个php文件里写html标签
- 求大牛指导 在php中failed to connect to mysql at 3306 with user root
- 用户上传的图片,大的图片如何压缩到2M以内
- 关于mysql单一表2次查询语句问题
- php程序显示空白是什么原因,帮忙看看
- 请问一个过通过代理调用某个类中的函数的传参数问题
- 想兼职的来,骗你我不是人
- 怎样批量更新
- 一个页面转向的方法提问
- 怎样用php实现?????
- php如何使用header直接下载图片?
- MYSQL 表出问题Table 'XX' is marked as crashed and should be repaired
{
$f='';
$data='';
foreach($p as $k=>$v)
{
$data.=$f.$k.'='.urlencode($v);
$f='&';
}
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$res = curl_exec($curl);
if(curl_errno($curl))
{
echo 'Curl error: ' . curl_error($curl);
}
curl_close($curl);
return $res;
}$x=_xpost('http://abc.com/aa.php',array( 'username'=>$uname,
));
<?xml version="1.0" encoding="UTF-8" ?>
<result>
<response>1</response>
</result>
我怎么获取<response>之间的1这个值?
preg_match('/<response>(.*?)<\/response>/s',$xml,$m);
echo $m[1];
xpath,或者直接操作dom都行。