imagestring
(PHP 3, PHP 4, PHP 5)
imagestring -- 水平地画一行字符串
说明
bool
imagestring ( resource image, int font, int x, int y, string s, int col )
imagestring() 用 col
颜色将字符串 s
画到 image
所代表的图像的 x
,y
坐标处(这是字符串左上角坐标,整幅图像的左上角为 0,0)。如果
font
是 1,2,3,4 或 5,则使用内置字体。
例 1. imagestring() 例子
<?php // 建立一幅 100X30 的图像 $im = imagecreate(100, 30);
// 白色背景和蓝色文本 $bg = imagecolorallocate($im, 255, 255, 255); $textcolor = imagecolorallocate($im, 0, 0, 255);
// 把字符串写在图像左上角 imagestring($im, 5, 0, 0, "Hello world!", $textcolor);
// 输出图像 header("Content-type: image/png"); imagepng($im); ?>
|
|
参见 imageloadfont() 和
imagettftext()。