【发布时间】:2020-09-07 19:40:32
【问题描述】:
我不断收到这些特殊字符符号:Bel�n。这些信息来自我的数据库。
我已经在各处添加了<meta charset="utf-8">,但它们似乎没有改变。
我猜这个错误与数据库连接有关。这是我的数据库连接代码,但我不知道在哪里添加字符集或如何添加。
namespace App\Classes\Model;
use PDO;
use PDOException;
class Database
{
public $databaseHandler;
public $host = "localhost";
public $dbname = "database";
public $user = "root";
public $password = "";
public function __construct()
{
try {
$this->databaseHandler = new PDO("mysql:host=$this->host;dbname=$this->dbname", $this->user, $this->password);
//echo "Database Connected";
}
catch(PDOException $error){
echo $error->getMessage();
}
}
}
【问题讨论】:
标签: php database utf-8 character-encoding special-characters