Latest web development tutorials

PHP imagechar – 寫出橫向字符

PHP 圖像處理 PHP圖像處理

imagechar — 寫出橫向的字符。

語法

bool imagechar ( resource $image , int $font , int $x , int $y , string $c , int $color )

imagechar() 將字符串c 的第一個字符畫在image 指定的圖像中,其左上角位於x,y(圖像左上角為0, 0),顏色為color。 如果font 是1,2,3,4 或5,則使用內置的字體(更大的數字對應於更大的字體)。

實例

<?php
$im = imagecreate(100,100);

$string = 'PHP';

$bg = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);

// 左上角输出字符 P
imagechar($im, 5, 0, 0, $string, $black);

header('Content-type: image/png');
imagepng($im);
?>

以上實例輸出結果的圖片如下:

PHP 圖像處理 PHP圖像處理