1

我需要有关该file_get_contents()功能的帮助。

当我尝试从包含一些希伯来语字符的 url 中获取数据时,我收到来自主机的错误(无效链接)。

例如:

file_get_contents('http://domain.com/page/עברית');

对我不起作用。

4

1 回答 1

0

网址不能包含 UTF-8 字符。它们必须首先进行 url 编码。它们可能在您的浏览器中显示为 UTF-8 字符,但这只是您的浏览器让它看起来更漂亮。

When a new URI scheme defines a component that represents textual
data consisting of characters from the Universal Character Set [UCS],
the data should first be encoded as octets according to the UTF-8
character encoding [STD63]; then only those octets that do not
correspond to characters in the unreserved set should be percent-
encoded.  For example, the character A would be represented as "A",
the character LATIN CAPITAL LETTER A WITH GRAVE would be represented
as "%C3%80", and the character KATAKANA LETTER A would be represented
as "%E3%82%A2".

https://www.rfc-editor.org/rfc/rfc3986#section-2.5

于 2013-03-17T23:14:44.350 回答