What to do if the php verification code is garbled

藏色散人
Release: 2023-03-07 10:42:01
Original
3349 people have browsed it

Solution to garbled php verification code: First determine the Chinese verification code text to be drawn; then pass "imagettftext($im,12,3,20,20,$te,'msyhbd.ttf',$ str);" method can solve the problem of garbled characters.

What to do if the php verification code is garbled

Recommended: "PHP Video Tutorial"

php utf8 page verification code picture Chinese garbled code

During development, the Chinese verification code on the uft-8 page was garbled. I found the reason by searching on Baidu. Friends who need it can refer to the solution below. The code is as follows: ? session_start(); // Generate random numbers for ( $i =0; $i 4; $i ){ $rand .= dechex (rand(1,15));

The Chinese verification code on the uft-8 page appears garbled during development Yes, I found the reason by searching on Baidu. Friends who need it can refer to the solution below. The code is as follows:

Copy after login

Analyze the cause and solution. The error code is as follows:

$str=iconv("gbk","utf-8","新年快乐!");//确定要绘制的中文文字 imagettftext($im,12,3,20,20,$te,'msyhbd.ttf','中文en');
Copy after login

Correct The code should look like this:

$str=iconv("gbk","utf-8","新年快乐!");//确定要绘制的中文文字 imagettftext($im,12,3,20,20,$te,'msyhbd.ttf',$str);
Copy after login

The above is the detailed content of What to do if the php verification code is garbled. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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!