[请益] curl网址后面加中文变乱码

楼主: a3236852 (serena)   2017-05-16 13:48:31
程式码如下,要$text进去curl之后就变成乱码了
找了很久的资料 不知道到底该怎么改才好
谢谢~
key跟id好像不方便公开XD结果会像这样
http://i.imgur.com/OnQGuTN.jpg
<?php
header("content-type:text/html;charset=utf-8");
$text="hello/你好";
// 设定撷取的URL网址
$url='https://westus.api.cognitive.microsoft.
com/luis/v2.0/apps/'.$id.'?subscription-key=
'.$key.'&timezoneOffset=0&verbose=true&q='.$text;
// 建立CURL连线
$c=curl_init();
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c,CURLOPT_RETURNTRANSFER,true);
curl_setopt($c, CURLOPT_BINARYTRANSFER, true) ;
curl_setopt($c, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($c,CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($c,CURLOPT_SSL_VERIFYPEER,0);
$fact=curl_exec($c);
$info=curl_getinfo($c);
curl_close($c);
echo $fact;
echo $url;
?>
作者: Phedra (Phedra)   2017-05-16 19:17:00
URL encode http://blog.ericsk.org/archives/1423这样才是符合标准规范的行为

Links booklink

Contact Us: admin [ a t ] ucptt.com