且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Php Curl在本地计算机上返回数据,但在服务器上布尔值为false

更新时间:2022-04-22 22:24:09

您应在卷曲错误,而不是仅查看curl_exec结果:

You should check at the curl error instead of only looking at the curl_exec result:


PHP 4> = 4.0.3,PHP 5,PHP 7)
curl_error —返回一个字符串,其中包含当前会话的最后一个错误

PHP 4 >= 4.0.3, PHP 5, PHP 7) curl_error — Return a string containing the last error for the current session

请尝试以下操作:

if(curl_exec($ch) === false) {
    echo 'Curl error: ' . curl_error($ch);
} else {
    echo 'Operation completed without any errors';
}


curl_close($ch);

更新

尝试设置以下内容:

'curl' => [ CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4]

有关更多详细信息,请参见此处

For more details check here