file_get_contents() 和特殊字符的问题
我正在使用 file_get_contents() 和包含特殊字符的 url。我从维基百科上挑选了一些网址进行检查。
我测试了我的“test1.php”
<?php
header('Content-Type: text/html; charset=UTF-8');
echo file_get_contents($_GET['url']);
?>
网址:(注意:这些链接中的特殊字符未正确显示。单击链接即可在地址栏上查看特殊字符)
http://localhost/te/test1.php?url=http://en.wikipedia.org/wiki/T%C3%A2i-l%C3%B4
--- - 上面的 URL 可以工作并显示内容,但下面的 URL 不起作用 ------
http://localhost /te/test1.php?url=http://en.wikipedia.org/wiki/Pha%CC%8Dk-oa-chhi_romanization
localhost/te/test1.php?url=http://en.wikipedia.org/wiki/Bb%C3%A1nl%C3%A1m_H%C5%8Dngggi%C3%A1n_P%C4%ABny%C4%ABn_H%C5% 8Dng%C3%A0n
我尝试了 mb_convert_encoding() 但没有解决...帮我解决这个问题。谢谢副词
I was working with file_get_contents() with urls containing special characters. i picked some urls from wikipedia for checking.
my "test1.php"
<?php
header('Content-Type: text/html; charset=UTF-8');
echo file_get_contents($_GET['url']);
?>
urls i tested:(note: the special characters are not properly displayed in these links..click on the link to see the special char at the address bar)
http://localhost/te/test1.php?url=http://en.wikipedia.org/wiki/T%C3%A2i-l%C3%B4
---- THE ABOVE URL WORKED and display the contents but BELOW DOESN'T WORK ------
http://localhost/te/test1.php?url=http://en.wikipedia.org/wiki/Pha%CC%8Dk-oa-chhi_romanization
localhost/te/test1.php?url=http://en.wikipedia.org/wiki/Bb%C3%A1nl%C3%A1m_H%C5%8Dngggi%C3%A1n_P%C4%ABny%C4%ABn_H%C5%8Dng%C3%A0n
I tried mb_convert_encoding() but it didnt solve... Help me to solve this.Thanks in adv.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此我相信你必须使用 . urlencode($变量);
for that I believe you have to use . urlencode($variable);