PHP imagechar - Write horizontal character

PHP 图像处理PHP Image Processing

imagechar — Write a horizontal character.

Syntax

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

imagechar() draws the first character of string c in the image specified by image, with its upper-left corner at x, y (the upper-left corner of the image is 0, 0), and the color as color. If font is 1, 2, 3, 4, or 5, a built-in font is used (larger numbers correspond to larger fonts).

Example

<?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);
?>

The image output of the above example is as follows:

PHP 图像处理PHP Image Processing

Other Extensions