Php/docs/function.imagestring

来自菜鸟教程
机器人讨论 | 贡献2020年12月10日 (四) 12:49的版本 (autoload)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至:导航、​搜索

imagestring

(PHP 4, PHP 5, PHP 7)

imagestring水平地画一行字符串


说明

imagestring ( resource $image , int $font , int $x , int $y , string $s , int $col ) : bool

imagestring()col 颜色将字符串 s 画到 image 所代表的图像的 xy 坐标处(这是字符串左上角坐标,整幅图像的左上角为 0,0)。如果 font 是 1,2,3,4 或 5,则使用内置字体。

Example #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()