Reason:
In the program I have a strict timeout limit for curl to get content, so it will cause the problem of unable to get the content.
WORKAROUND: Set default access to IPv4.
The Curl settings for PHP are as follows:
Copy CodeThe code is as follows:
/**
* IPV6 Curl Timeout problem
*/
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, Curlopt_returntransfer, true);
Set Curl default access to IPV4
if (defined (' curlopt_ipresolve ') && defined (' curl_ipresolve_v4 ')) {
curl_setopt ($ch, Curlopt_ipresolve, CURL_IPRESOLVE_V4);
}
Sets the maximum number of seconds when curl requests a connection, and if set to 0, the infinite
curl_setopt ($ch, Curlopt_connecttimeout, $timeout);
Sets the maximum number of seconds that curl will perform the total action, and if set to 0, the infinite
curl_setopt ($ch, Curlopt_timeout, $timeout);
$file _contents = curl_exec ($ch);
Curl_close ($ch);
Note:curl_setopt ($ch, Curlopt_ipresolve, CURL_IPRESOLVE_V4) The above settings will only take effect if the version of PHP version 5.3 and later, CURL version 7.10.8 and above.
http://www.bkjia.com/PHPjc/328038.html www.bkjia.com true http://www.bkjia.com/PHPjc/328038.html techarticle cause: In the program I have made a strict timeout limit on curl acquisition, so it will cause the problem of unable to get the content. WORKAROUND: Set default access to IPv4. PHP's ...