]."/> ].">
Home > Article > Backend Development > What should I do if the Chinese characters output by echo in PHP are garbled?
The Chinese output by echo shows garbled characters, which is basically an encoding problem.
Generally speaking, for the sake of encoding compatibility, most pages define the page character set as utf-8
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
At this time, to display Chinese normally, you need to convert the encoding method, such as
echo iconv("GB2312","UTF-8",'中文');
This way there will be no garbled characters.
There are other methods, such as adding
header("Content-Type:text/html;charset=gb2312");
in front of php’s echo. For more related tutorials, please pay attention to php中文网.
The above is the detailed content of What should I do if the Chinese characters output by echo in PHP are garbled?. For more information, please follow other related articles on the PHP Chinese website!