get the value of an url response with curl

前端 未结 1 386
刺人心
刺人心 2020-12-07 03:47

I am using PHP curl method to get a string type response. To create the request I use:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($c         


        
相关标签:
1条回答
  • 2020-12-07 04:12

    Since you already have

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    

    in your code. curl_exec should already returns the content of the page instead of a BOOL.

    This is a snippet of a library I use. As pointed out this might not be needed but it helped me out once...

    //The content - if true, will not download the contents
    curl_setopt($ch, CURLOPT_NOBODY, false);
    

    Also it seems to have some bugs related to CURLOPT_NOBODY (which might explain why you have this issue):

    • http://osdir.com/ml/web.curl.general/2005-07/msg00073.html
    • http://curl.haxx.se/mail/curlphp-2008-03/0072.html
    0 讨论(0)
提交回复
热议问题