(PHP 4, PHP 5, PHP 7, PHP 8)
imagestring — 水平地畫一行字符串
$image,$font,$x,$y,$s,$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);
?>