Home >php教程 >php手册 >PHP 生成中文验证码乱码问题解决(1/2)

PHP 生成中文验证码乱码问题解决(1/2)

WBOY
WBOYOriginal
2016-06-13 09:54:421346browse

PHP 生成中文验证码乱码问题解决
//将要处理的汉字,先由UTF8的汉字转成html实体形式再使用.

//示例代码:

//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 = '中华人民共和国';
$str = mb_convert_encoding($str, "html-entities","utf-8" );//结果:哪一队优先开球

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 示例代码:

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

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