Easy Tutorial
❮ Php Ref Mysqli Func Zip Entry Close ❯

PHP imagechar - Write Horizontal Character

PHP Image Processing

imagechar — Writes 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 specified image identified by image, with its upper-left corner at coordinates x, y (top-left being 0, 0) with the specified color. If font is 1, 2, 3, 4, or 5, the built-in fonts are used (with higher numbers corresponding to larger fonts).

Example

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

$string = 'PHP';

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

// Output the character P at the top-left corner
imagechar($im, 5, 0, 0, $string, $black);

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

The above example outputs an image as follows:

PHP Image Processing

❮ Php Ref Mysqli Func Zip Entry Close ❯