且构网

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

PHP curl无法解析纯IPv6 URL

更新时间:2023-02-23 18:28:01

您的期望 CURLOPT_IPRESOLVE 是正确的,这确实是应该做的。但是,您似乎为该值使用了错误的常数。从手册中:

Your expectations of CURLOPT_IPRESOLVE are correct, that is indeed what it is supposed to do. However you seem to have used a wrong constant for the value. From the manual:


CURLOPT_IPRESOLVE :允许应用程序选择要处理的IP
地址类型在解析主机名时使用。仅当使用主机名解析IP地址超过一个
版本的
时,这才是有趣的,可能的值为 CURL_IPRESOLVE_WHATEVER
CURL_IPRESOLVE_V4 >, CURL_IPRESOLVE_V6 ,默认为
CURL_IPRESOLVE_WHATEVER

CURLOPT_IPRESOLVE: Allows an application to select what kind of IP addresses to use when resolving host names. This is only interesting when using host names that resolve addresses using more than one version of IP, possible values are CURL_IPRESOLVE_WHATEVER, CURL_IPRESOLVE_V4, CURL_IPRESOLVE_V6, by default CURL_IPRESOLVE_WHATEVER.

I找不到手册中使用的常量( CURL_VERSION_IPV6 ),因此IIRC然后PHP将其解释为字符串 CURL_VERSION_IPV6 无效。

I can't find the constant you use (CURL_VERSION_IPV6) in the manual, so IIRC then PHP will interpret it as the string "CURL_VERSION_IPV6" which won't work.