模拟POST方法提交表单三个要点

  1. 声明是post方法

    curl_setopt($curl,CURLOPT_POST,1);
  2. 表单提交的数据

    $data = "username=zhangsan&sex=male";
    curl_setopt($curl,CURLOPT_POSTFIELDs,$data);
  3. POST提交的头信息

    curl_setopt($curl,CURLOPT_HTTPHEADER,
    array("application/x-www-form-urlencoded;charset=utf-8","Content-length:".strlen($data)));

转载于:https://www.cnblogs.com/jhcyzxx/p/10479813.html

你可能感兴趣的:(模拟POST方法提交表单三个要点)