开发者

PHP cURL get content with accented URL

开发者 https://www.devze.com 2023-01-21 13:04 出处:网络
Using cURL with an accented URL, I cannot get content if CURLO开发者_高级运维PT_RETURNTRANSFER = true.

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

精彩评论

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