'mysql:host=127.0.0.1; dbname=ohmycto; charset=utf8',"; and finally save the changes."/> 'mysql:host=127.0.0.1; dbname=ohmycto; charset=utf8',"; and finally save the changes.">

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

How to solve yii Chinese garbled characters

藏色散人
藏色散人Original
2020-07-22 11:48:373202browse

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;,
];

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!

Statement:
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
Previous article:How to open yii with zendNext article:How to open yii with zend