开发者

PHP cURL get content with accented URL

Using cURL with an accented URL, I cannot get content if CURLO开发者_高级运维PT_RETURNTRANSFER = true.

Example:

$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, "http://fr.wikipedia.org/wiki/Été");
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, true);
$html = curl_exec ($curl);
echo $html;

$html is empty, does someone have a solution ?


Try using urlencode for the accent part of the url:

curl_setopt ($curl, CURLOPT_URL, "http://fr.wikipedia.org/wiki/" . urlencode("Été"));

And see what happens.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜