Yii Chinese garbled solution: first find the database configuration file; then modify the code statement to "'dsn' => 'mysql:host=127.0.0.1; dbname=ohmycto; charset=utf8'," ;Finally save the changes.
About the Chinese garbled problem of yii2
Recommended: "yii tutorial"
Just configure it like this in the database configuration
<?php return [ 'class' => 'yii\db\Connection', 'dsn' => 'mysql:host=127.0.0.1; dbname=ohmycto; charset=utf8', 'username' => 'website', 'password' => 'mengde1B', ];
Simple summary:
If the database output is garbled, it is recommended to modify the character set when configuring the local data. For 'charset' => 'utf8mb4', or 'charset' => 'utf8', if there is a problem with the page, there may be a problem with the character encoding of your page. Yii2 defaults to UTF-8.
The above is the detailed content of How to solve yii Chinese garbled characters. For more information, please follow other related articles on the PHP Chinese website!