Solution to garbled Chinese watermark in php: 1. Add the statement "utf-8"; 2. Use iconv to convert the text to be generated to "utf-8"; 3. Change the function to generate text to "ImageTTFText" function.
The problem of Chinese garbled characters when php generates text watermarks
In the past two days, I helped colleagues test the synthesis of pictures and text The result is that there is no problem with image synthesis, but when synthesizing text, I encountered a small problem. The Chinese text was always garbled. I thought at first that the declaration utf-8 was not added. After adding it, I found that it still didn't work. Then I used iconv to generate the text. Converting to utf-8 still doesn't work. After searching, I finally found that there is a problem with the function used to generate text. I used this imagestring() before. It seems that this function does not support Chinese, so I changed it to ImageTTFText
Enough.
For more related knowledge, please visit PHP Chinese website!
The above is the detailed content of What to do if php Chinese watermark is garbled. For more information, please follow other related articles on the PHP Chinese website!