我的数据库设置为UTF8 GENERAL CI
,作为我的表的排序规则。但是当我尝试使用以下PHP代码输出时,问号会显示为代替UTF字符(我正在尝试打印区域语言字符)...
以下是我的代码:
<?php
class Article implements JsonSerializable{
private $id;
private $title;
private $content;
public function getId() {
return $this->id;
}
public function getTitle() {
return $this->title;
}
public function getContent() {
return $this->content;
}
public static function getById($id) {
$db = newMysqli ();
$query = "select * from articles where _id=?";
$stmt = $db->prepare ( $query ) or dieOnError ( $db );
$stmt->bind_param ( "i", $id ) or dieOnError ( $db );
$stmt->execute () or dieOnError ( $db );
$member = new Article();
$stmt->bind_result ( $member->id, $member->title, $member->content);
$stmt->fetch () or dieOnError ( $db );
$stmt->close ();
return $member;
}
public function jsonSerialize(){
return get_object_vars($this);
}
}
答案 0 :(得分:0)
尝试将文件编码更改为UTF-8。 (Notepad ++中的编码菜单 - &gt;转换为UTF-8)