Is there any way to force cURL to use IPv4? I'm looking for like a global setting, like php.ini
setting or something like that.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Please try this code, with curl_setopt
This will force the IPV4 resolving.
if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
}
the defined insure that the global constants available on your PHP version.