您好,欢迎访问一九零五行业门户网

PHP中 GET 与 POST

get 数据请求
$url = http://www.xxxx.com?user=111;$ch = curl_init();curl_setopt($ch, curlopt_url, $url);curl_setopt($ch, curlopt_returntransfer, 1);curl_setopt($ch, curlopt_header, 0);$out = curl_exec($ch);curl_close($ch);$obj = json_decode($out);print $obj;
post 数据发送
$url = http://www.xxxx.com?user=111;$post_data = somedata;$ch = curl_init();curl_setopt($ch, curlopt_url, $url);curl_setopt($ch, curlopt_returntransfer, 1);curl_setopt($ch, curlopt_header, 0);curl_setopt($ch , curlopt_post , 1 ) ;curl_setopt($ch , curlopt_postfields , $post_data ) ;$out = curl_exec($ch);curl_close($ch);$obj = json_decode($out);print $obj;
curl_setopt  主要是这个方式的使用 千变万化。 http://php.net/manual/zh/function.curl-setopt.php 可以去文档中去 找寻更多的选项。
有一次还用到 这两个 选项
curl_setopt($ch, curlopt_ssl_verifypeer, false); curl_setopt($ch,curlopt_ssl_verifyhost,false);
反正在 post不到数据的时候,要多看看选项。
post 数据接收
$post_data = file_get_contents(php://input);$post_data = trim($post_data);print $post_data;
其它类似信息

推荐信息