码迷,mamicode.com
首页 > Web开发 > 详细

php curl

时间:2016-03-23 12:53:36      阅读:170      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!