Home > Article > Backend Development > What to do if php watermark is garbled
Solution to garbled watermark in php: 1. Remove the "--enable-gd-jis-conv" option and recompile php; 2. Convert characters to html entities using the method "mb_convert_encoding ()".
php Use Gd library to add garbled text watermark problems and solutions
A recent project After migrating the server, it was discovered after deployment that one of the functions of adding watermark text to pictures had a garbled problem. It was confirmed that there was no problem with the function code. At the same time, the project codes were all encoded in UTF-8, and there was no encoding problem. The fonts were also checked and excluded. There is a possibility of a problem with the file. After consulting the information, I finally found a PHP compilation parameter --enable-gd-jis-conv.
--enable-gd-jis-conv:
If the --enable-gd-jis-conv option is enabled when compiling PHP, non-ASCII characters (such as Chinese characters, pinyin, Greek and arrows) will be regarded as EUC-JP encoding, eventually leading to normal Chinese changes. Into garbled characters
Solution:
1. Remove the --enable-gd-jis-conv option and recompile php
2. Convert characters to html entities
mb_convert_encoding ('测试', 'HTML-ENTITIES', 'UTF-8');
Recommended: "PHP Tutorial"
The above is the detailed content of What to do if php watermark is garbled. For more information, please follow other related articles on the PHP Chinese website!