How to solve the garbled code of php7 iconv and mb_convert_encoding?

I have tried the following ways, either garbled or reported an error.

$strInput = "Li Li ad ss";

/ / output is normal, no garbled
echo $strInput;

/ /: iconv (): Unknown error
echo iconv ("utf-8","gb2312",$strInput);

/ / garbled
echo iconv ("utf-8","gb2312//IGNORE",$strInput);

/ / garbled
echo iconv ("utf-8","GBK",$strInput);

/ / garbled
echo mb_convert_encoding ($strInput, "GBK", "UTF-8");

/ / garbled
echo mb_convert_encoding ($strInput, "GBK");

Mar.10,2022

the main question is what kind of encoding is set in the charset of your page?


is the encoding of the file normal? Try creating a new file using notpad+

Menu