模拟POST方法提交表单三个要点
-
声明是post方法
curl_setopt($curl,CURLOPT_POST,1);
-
表单提交的数据
$data = "username=zhangsan&sex=male"; curl_setopt($curl,CURLOPT_POSTFIELDs,$data);
-
POST提交的头信息
curl_setopt($curl,CURLOPT_HTTPHEADER, array("application/x-www-form-urlencoded;charset=utf-8","Content-length:".strlen($data)));