Home  >  Article  >  php教程  >  PHP中利用GD输出汉字实例

PHP中利用GD输出汉字实例

WBOY
WBOYOriginal
2016-06-13 11:16:33958browse

 

//定义输出为图像类型
header("content-type:image/gif");
//新建图象
$pic=imagecreate(240,30);
//定义黑白颜色
$black=imagecolorallocate($pic,0,0,0);
$white=imagecolorallocate($pic,255,255,255);
//定义字体
$font="c://WIN2000//fonts//simhei.ttf";
//定义输出字体串
$str = chr(0xE8).chr(0xB5).chr(0x9B).chr(0xE8).chr(0xBF).chr(0xAA).chr(0xE7).chr(0xBD).chr(0x91)." http://www.itbbs.cn";
//写 TTF 文字到图中
imagettftext($pic,12,0,10,20,$white,$font,$str);
//建立 GIF 图型
imagegif($pic);
//结束图形,释放内存空间
imagedestroy($pic);
?>


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