每当我尝试使用抓取页面的内容file_get_contents(),并且域中包含unicode字符时,我会得到:
file_get_contents(https://møller.dk/):无法打开流:php_network_getaddresses:getaddrinfo failed:>文件位置中未知的服务名称<
只有在域中有unicode字符时才会发生这种情况.这是一个例子:
file_get_contents("http://møller.dk/");
Run Code Online (Sandbox Code Playgroud)
你需要使用这个idn_to_ascii()功能:
file_get_contents('http://' . idn_to_ascii('møller.dk'));
Run Code Online (Sandbox Code Playgroud)
参考:
| 归档时间: |
|
| 查看次数: |
1558 次 |
| 最近记录: |