What to do if php watermark is garbled

藏色散人
Release: 2023-03-01 20:44:01
Original
2052 people have browsed it

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 ()".

What to do if php watermark is garbled

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');
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!