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 所代表的圖像的 xy 坐標處(這是字串左上角坐標,整幅圖像的左上角為 0,0)。若果 font 是 1,2,3,4 或 5,則使用內建字型。

例子 1. imagestring() 例子

<?php
// 建立一幅 100X30 的圖像
$im imagecreatetruecolor(10030);

// 白色背景和藍色文字
$bg imagecolorallocate($im255255255);
$textcolor imagecolorallocate($im00255);

// 把字串寫在圖像左上角
imagestring($im500"Hello world!"$textcolor);

// 輸出圖像
header("Content-type: image/jpeg");
imagejpeg($im);
?>

參見 imageloadfont()imagettftext()