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