Home >Backend Development >PHP Tutorial >Chinese garbled code in PHP's imagettftext method
Analysis:
1. Confirm whether the gb library is installed correctly? If there is no report, this method does not exist.
2. imagettftext() must be encoded in utf-8. The entire PHP project is encoded in utf-8, so you don’t need to think too much. If not, you can convert it with mb_convert_encoding();
3. Check whether the font is loaded correctly, write down the font path, and change multiple fonts (commonly used Chinese font files are simsun.ttc and simhei.ttf), if it still doesn’t work, confirm It shouldn't be a font issue.
Then I saw someone online saying: Please check whether you added the –enable-gd-jis-conv option when compiling the gd library. This option is to allow the gd library to support Japanese-encoded fonts. Please cancel this option and recompile. .
Then I checked my php compilation options and found that this parameter was added. Do I need to recompile?
Just when my balls hurt, I saw another article:
$str=mb_convert_encoding('Chinese characters', "html-entities", "utf-8"); //Convert to html encoding