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

PHP中curl的使用

时间:2020-04-13 12:18:28      阅读:96      评论:0      收藏:0      [点我收藏+]

标签:ring   失败   stop   header   post提交数据   comm   成功   alt   environ   

curl_init()

返回一个 cURL handle


curl_setopt()

为cURL handle设置参数,格式为 CURLOPT_XXX
常用参数:

  • CURLOPT_URL:url

  • CURLOPT_REFERER:Referer提交的页面

  • CURLOPT_POST:是否是post请求

  • CURLOPT_TIMEOUT:超时时间

  • CURLOPT_HTTPHEADER:head请求数据

  • CURLOPT_HEADER:

  • CURLOPT_SSL_VERIFYPEER:FALSE to stop cURL from verifying the peer‘s certificate. Alternate certificates to verify against can be specified with the CURLOPT_CAINFO option or a certificate directory can be specified with the CURLOPT_CAPATH option.

  • CURLOPT_SSL_VERIFYHOST:1 to check the existence of a common name in the SSL peer certificate. 2 to check the existence of a common name and also verify that it matches the hostname provided. 0 to not check the names. In production environments the value of this option should be kept at 2 (default value).

  • CURLOPT_RETURNTRANSFER:TRUE to return the transfer as a string of the return value of curl_exec() instead of outputting it directly.

  • CURLOPT_POSTFIELDS:post提交数据


curl_exec()

执行请求,如果设置了 CURLOPT_RETURNTRANSFER,成功会返回结果,失败返回false。


curl_close()

关闭


PHP中curl的使用

标签:ring   失败   stop   header   post提交数据   comm   成功   alt   environ   

原文地址:https://www.cnblogs.com/jiaoran/p/12690285.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!