Home  >  Article  >  PHP Framework  >  Solution to garbled code problem in yii2 console

Solution to garbled code problem in yii2 console

藏色散人
藏色散人Original
2020-07-20 10:53:442586browse

yii2 The solution to console garbled characters: first find and open the corresponding script file; then modify the code statement to "$content = iconv("utf-8","gb2312//IGNORE",$content); ”; finally save the changes.

Solution to garbled code problem in yii2 console

Solution to the problem of Chinese garbled characters normally encountered on the cmd command prompt when Yii2 console executes a scheduled script [Version 2.0]

Specific question:

$content="你好,世界";
$content = iconv("utf-8","gb2312//IGNORE",$content);
echo $content . "\n";

Normally the method we use is this:$data=iconv("GB2312", "UTF-8",$string);

Filtering errors Yes: //IGNORE

Recommended: "yii tutorial"

##Correct usage :

$content = iconv("utf-8","gb2312//IGNORE",$content);

The above is the detailed content of Solution to garbled code problem in yii2 console. 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