gpt4 book ai didi

php代码不输出utf 8字符?

转载 作者:行者123 更新时间:2023-11-29 21:10:57 24 4
gpt4 key购买 nike

我的数据库设置为 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);
}

}

最佳答案

尝试将文件编码更改为UTF-8。 (Notepad++ 中的编码菜单 -> 转换为 UTF-8)

关于php代码不输出utf 8字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36376368/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com