如何使用PHP和Android从web服务发送和检索数据
我正在开发一个应用程序,在这个应用程序中,我从web服务获取数据,并在Android mobile中显示。但问题是,在获取土耳其数据时,数据显示不正确 我已经在PHP中设置了如何使用PHP和Android从web服务发送和检索数据,php,android,xml,encoding,Php,Android,Xml,Encoding,我正在开发一个应用程序,在这个应用程序中,我从web服务获取数据,并在Android mobile中显示。但问题是,在获取土耳其数据时,数据显示不正确 我已经在PHP中设置了utf-8。但仍然会得到特殊的字符符号,如A?ı;k#287用于字符串Açıkğretim 以下是我的PHP代码: <?php include("Netbrut_class.php"); header('Content-type: text/xml; charset: utf-8'); $webser
utf-8
。但仍然会得到特殊的字符符号,如A?ı;k#287
用于字符串Açıkğretim
以下是我的PHP代码:
<?php
include("Netbrut_class.php");
header('Content-type: text/xml; charset: utf-8');
$webservice = new Netbrut;
$content='<?xml version="1.0" encoding="utf-8"?><salary_comparision>';
$education = $webservice->select_education();
for($i=0; $i<count($education); $i++){
$string = html_entity_decode($education[$i]['comparision_name'], ENT_QUOTES, "utf-8");
$content.="<education id='".$education[$i]['id']."'>".$string."</education>";
}
$content .='</salary_comparision>';
echo $content;
?>
从web服务返回的XML是:
<?xml version="1.0" encoding="utf-8"?>
<salary_comparision>
<education id='128'>A?ık ?ğretim</education>//Check here
<education id='5'>Doktora</education>
<education id='3'>Master</education>
<education id='4'>MBA</education>
<education id='2'>?niversite</education>
</salary_comparision>
答305 ;;k#287;retim//在这里检查
多克托拉
主人
工商管理硕士
大学
在Php代码中,只需更改以下几行即可
$string = html_entity_decode($education[$i]['comparision_name'], ENT_QUOTES, "utf-8");
$content.="<education id='".$education[$i]['id']."'>".$string."</education>";
$string=html\u entity\u decode($education[$i]['comparison\u name'],ENT\u引号,“utf-8”);
$content.=''.$string.'';
到
$string=$webservice->unhtmlspecialchars($education[$i]['comparision\u name');
$content.=''.$string.'';
请参阅Php代码中的。,只需更改以下几行即可
$string = html_entity_decode($education[$i]['comparision_name'], ENT_QUOTES, "utf-8");
$content.="<education id='".$education[$i]['id']."'>".$string."</education>";
$string=html\u entity\u decode($education[$i]['comparison\u name'],ENT\u引号,“utf-8”);
$content.=''.$string.'';
到
$string=$webservice->unhtmlspecialchars($education[$i]['comparision\u name');
$content.=''.$string.'';
看
$string = $webservice->unhtmlspecialchars($education[$i]['comparision_name']);
$content.="<education id='".$education[$i]['id']."'>".$string."</education>";