Home > PHP Framework > YII > How to solve yii Chinese garbled characters

How to solve yii Chinese garbled characters

藏色散人
Release: 2020-07-22 11:48:37
Original
3304 people have browsed it

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.

How to solve yii Chinese garbled characters

About the Chinese garbled problem of yii2

Recommended: "yii tutorial"

Just configure it like this in the database configuration

<?php
return [
    &#39;class&#39; => &#39;yii\db\Connection&#39;,
    &#39;dsn&#39; => &#39;mysql:host=127.0.0.1; dbname=ohmycto; charset=utf8&#39;,
    &#39;username&#39; => &#39;website&#39;,
    &#39;password&#39; => &#39;mengde1B&#39;,
];
Copy after login

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!

Related labels:
yii
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template