Php 从URL content/JSON读取中文字符-Google Places
我放弃了。经过两天的研究,我想问一下专家。 我正在尝试通过PHP读取Google Place信息,我正在这样做:Php 从URL content/JSON读取中文字符-Google Places,php,utf-8,chinese-locale,Php,Utf 8,Chinese Locale,我放弃了。经过两天的研究,我想问一下专家。 我正在尝试通过PHP读取Google Place信息,我正在这样做: $link = "https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJIwa7XTyIGGARGn0k_6aUb8I&language=ja&key=APIKEY"; echo getContent($link); function getContent($link){
$link = "https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJIwa7XTyIGGARGn0k_6aUb8I&language=ja&key=APIKEY";
echo getContent($link);
function getContent($link){
if(!$fp = fopen($link ,"r" )) {
echo "false";
}else{
$tmp = "";
while(!feof($fp)) {
$tmp .= fgets($fp, 1024);
}
fclose($fp);
}
return $tmp;
}
虽然这对所有美国和欧洲的地方都很有效,但我很难用中文和俄文字符(例如姓名或地址)
预期输出:BumB東京スポーツ文化館 (例如名称:通过浏览器)
收到的输出:通过PHP
我知道这是某种编码错误,但不知道如何处理。尝试了各种UTF8编码,但迄今为止没有成功
感谢您的支持,帮助我找到解决方案!
fj有时候这很容易 PHP没有将默认值设置为uft8,这就成功了:
header('Content-Type: text/html; charset=utf-8');
希望有一天这能帮助那些痛苦的人 标题('Content-Type:text/html;charset=utf-8');看来我找到了解决办法。这比预期的容易!