Home  >  Article  >  Backend Development  >  What to do if php Chinese watermark is garbled

What to do if php Chinese watermark is garbled

藏色散人
藏色散人Original
2020-07-11 10:44:032801browse

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.

What to do if php Chinese watermark is garbled

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 ImageTTFTextEnough.

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn