[英]How to pass a UTF-8 URL to cURL?
I have a table in UTF-8 format. 我有一个UTF-8格式的表格。 I want to read data from the database and then to curl get content.
我想从数据库中读取数据,然后卷曲获取内容。 I pass url in UTF-8 format, but I can't get content.
我以UTF-8格式传递url,但无法获取内容。 what should I do to solve the problem?
我该怎么办才能解决问题?
I use below code, but had a problem: 我使用下面的代码,但是有一个问题:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$this->content = curl_exec($ch);
curl_close($ch);
尝试先utf8_encode
,然后urlencode()
URL,
$url = urlencode(utf8_encode($url));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.