开发者

PHP: curl_init() giving NULL although created the resource

开发者 https://www.devze.com 2023-02-11 08:10 出处:网络
I\'m facing an error: Warning: curl_exec() expects parameter 1 to be resource, null given in $json_string = curl_exec($variable_curl);

I'm facing an error:

Warning: curl_exec() expects parameter 1 to be resource, null given in

$json_string = curl_exec($variable_curl);

I'm not sure what was wrong. I have

function __construct() {

      $variable_curl = curl_init(); //Create a new cURL resource

    }

I've confirmed the curl binding is working correctly because I used it without creating a library.

Based on that error, I can only tell $variable_curl wasn't created as a cURL resource corre开发者_运维技巧ctly/non at all. But by looking at the function __construct above, I've done it.


Is $variable_curl a global variable? If not, it won't be visible outside of your constructor. If so, you need to declare it as such inside the function:

global $variable_curl;
0

精彩评论

暂无评论...
验证码 换一张
取 消