Home  >  Article  >  Backend Development  >  Solving the problem of garbled Chinese verification code generated by PHP (1/2)_PHP tutorial

Solving the problem of garbled Chinese verification code generated by PHP (1/2)_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:53:491090browse

Solution to the problem of garbled Chinese verification code generated by PHP
//The Chinese characters to be processed are first converted from UTF8 Chinese characters into html entity form before use.

//Sample code:

//ini_set('JIS-mapped Japanese Font Support',false);
$pic=imagecreate(250,30);
$black=imagecolorallocate($pic,0,0,0);
$white=imagecolorallocate($pic,255,255,255);
$font="C://WINDOWS//Fonts//simhei.ttf";

$str = 'People's Republic of China';
$str = mb_convert_encoding($str, "html-entities","utf-8" );//Result:哪一队优先开& #29699;

imagettftext($pic,10,0,10,20,$white,$font,$str);

header("Content-type: image/jpeg");
$filename='./photo.jpg';
$im=imagecreatefromjpeg($filename);
imagecopymerge($im,$pic,0,0,0,0,250,30,50);
imagejpeg($im);


//pChart sample code:

/*
Example14: A smooth flat pie graph
*/ 1 2

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632369.htmlTechArticleSolution to the problem of garbled Chinese verification codes generated by PHP //The Chinese characters to be processed are first converted from UTF8 Chinese characters into html entities Reuse the form. //Sample code: //ini_set('JIS-mapped Japanese Font Support'...
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