2013-03-17 81 views
0

我需要file_get_contents()函數的幫助。使用file_get_contents和希伯來字符串

當我試圖從包含一些希伯來字符的url中獲取數據時,我從主機(無效鏈接)收到錯誤。

例如:

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

不爲我工作。

+0

什麼錯誤說?你有沒有試過utf8_encode? – Jonast92 2013-03-17 23:13:00

+0

對希伯來字符進行URL編碼可能工作 – ajreal 2013-03-17 23:14:50

+0

該URL在瀏覽器中不起作用 – MatRt 2013-03-17 23:14:52

回答

0

網址不能包含UTF-8字符。他們必須先進行網址編碼。它們可能會在瀏覽器中顯示爲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". 

http://tools.ietf.org/html/rfc3986#section-2.5

+0

你有一個鏈接到RFC的地方,它說任何機會? – PeeHaa 2013-03-17 23:18:17

+0

我加了。希望它有助於:) – Evert 2013-03-17 23:31:15

+0

@ evert。謝謝! – PeeHaa 2013-03-17 23:41:55