首页 > Web开发 > 详细

php curl

时间:2016-03-23 12:50:59      阅读:186      评论:0      收藏:0      [点我收藏+]

curl 模拟post提交

 1 $url = ‘http://localhost/url.php‘;
 2 
 3 $arr = [
 4     ‘username‘ => ‘Tom‘,
 5     ‘age‘ => 20,
 6     ‘sex‘ => ‘男‘
 7 ];
 8 $ch = curl_init();
 9 
10 curl_setopt($ch, CURLOPT_URL, $url);
11 curl_setopt($ch, CURLOPT_HEADER, 0);
12 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
13 curl_setopt($ch, CURLOPT_POST, 1);
14 curl_setopt($ch, CURLOPT_POSTFIELDS, $arr);
15 
16 $data = curl_exec($ch);
17 
18 var_dump(json_decode($data));

 

php curl

原文:http://www.cnblogs.com/bozo/p/5310352.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!