Home>Article>Backend Development> What to do if php variable outputs garbled characters
Solution to garbled output of php variables: 1. Convert through "iconv("GB2312","UTF-8",'Chinese');"; 2. Change UTF-8 to gb2312; 3 , modify the php.ini file configuration.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
The Chinese output by echo is displayed as garbled characters,
In fact, various server scripts should encounter this problem.
It is basically an encoding problem.
Generally speaking, most pages use the page character set for encoding compatibility reasons. Defined as utf-8
At this time, to display Chinese normally, you need to convert the encoding method, such as
echo iconv("GB2312","UTF-8",'Chinese' ; ;
I encountered a strange phenomenon in practice.
PHP Video Tutorial
"The above is the detailed content of What to do if php variable outputs garbled characters. For more information, please follow other related articles on the PHP Chinese website!