imagechar

(PHP 4, PHP 5, PHP 7, PHP 8)

imagechar水平地畫一個字符

說明

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

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

示例 #1 imagechar() 例子

<?php

$im 
imagecreate(100,100);

$string 'PHP';

$bg imagecolorallocate($im255255255);
$black imagecolorallocate($im000);

// prints a black "P" in the top left corner
imagechar($im100$string$black);

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

?>

參見 imagecharup()imageloadfont()。