php图片支持中文
<?php// 设定图像编码头部
header("Content-type: image/png");
// 创建图像
$im = imagecreatetruecolor(800, 600);
//创建颜色
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 800, 600, $white);
// 绘制的字符
$text = '学习中php';
// 导入字体 在c:/windows/fonts/simkai.ttf
$font = 'simkai.ttf';
// Add some shadow to the text
$text=iconv("gb2312","utf-8",$text);
imagettftext($im,20,20, 11, 110, $grey, $font, $text);
// Add the text
imagettftext($im,70,0,10,200, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>
页:
[1]