好的,这是我的数据库,我在 HTML 实体中有一些标题,还有一些带有普通字符的标题:
TITLE
MAMÁ
MAMÁ
所以我的问题是当我调用标题时:
/* If connection to database, run sql statement. */
if ($conn)
{
$fetch = mysql_query("SELECT * FROM test where title_test like '%" . mysql_real_escape_string($_GET['term']) . "%' and test_stock<>0");
/* Retrieve and store in array the results of the query.*/
while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
$row_array['id'] = $row['id_test'];
$row_array['value'] = $row['title_test'];
array_push($return_arr,$row_array);
}
}
/* Free connection resources. */
mysql_close($conn);
/* Toss back results as json encoded array. */
echo json_encode($return_arr);
结果如下:
OUTPUT
MAMÁ
NULL
所以我补充说mysql_set_charset('utf8',$conn);
:
这就是我的结果:
OUTPUT
MAMÁ
MAMÁ
我如何解码带有 HTML 实体的标题并让它们打印出来:
OUTPUT
MAMÁ
MAMÁ