php - file_get_contents fails to get a link with some perso-arabic characters -
this link works ok when open in browser
but when this
$link = 'http://www.bama.ir/خريد-خودرو/?ac411129-3-0-0-0-0-0-900000000-1/کادنزا-كیا'; echo file_get_contents($link);
i
( ! ) warning: file_get_contents(http://www.bama.ir/خريد-خودرو/?ac411129-3-0-0-0-0-0-900000000-1/کادنزا-كیا): failed open stream: http request failed! http/1.1 404 not found in
i think it's becuz of characters @ end of link (it works ok if replace them latin characters )
is there urlencode function file_get_contents ?
----------------- edit --------------------------
$link = urlencode('http://www.bama.ir/خريد-خودرو/?ac411129-3-0-0-0-0-0-900000000-1/کادنزا-كیا'); echo file_get_contents("$link");
result
warning: file_get_contents(http%3a%2f%2fwww.bama.ir%2f%d8%ae%d8%b1%d9%8a%d8%af-%d8%ae%d9%88%d8%af%d8%b1%d9%88%2f%3fac411129-3-0-0-0-0-0-900000000-1%2f%da%a9%d8%a7%d8%af%d9%86%d8%b2%d8%a7-%d9%83%db%8c%d8%a7): failed open stream: no such file or directory in c:\wamp\www\index.php on line 12
the link can converted using urlencode
string file_get_contents
understands. example:
echo file_get_conents("http://www.bama.ir/%d8%ae%d8%b1%d9%8a%d8%af-%d8%ae%d9%88%d8%af%d8%b1%d9%88/?ac411129-3-0-0-0-0-0-900000000-1/%da%a9%d8%a7%d8%af%d9%86%d8%b2%d8%a7-%d9%83%db%8c%d8%a7");
Comments
Post a Comment