问题描述
|
我正在使用包含特殊字符的URL处理file_get_contents()。我从维基百科中选择了一些网址进行检查。
我的“ 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-1%C3%B4
----上面的网址有效,并显示了内容,但以下却无效------
http://localhost/te/test1.PHP?url = http://en.wikipedia.org/wiki/Pha%CC%8Dk-oa-chhi_romanization
本地主机/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(),但是它没有解决...帮助我解决这个问题。感谢adv。
解决方法
为此,我相信您必须使用。 urlencode($ variable);