Draw a character horizontally in PHP

Description

The following code shows how to draw a character horizontally.

Example


<?php/* ww  w  .j a  v  a  2  s  . co m*/

$im = imagecreate(100, 100);

$string = 'PHP';

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

// prints a black "P" in the top left corner
imagechar($im, 1, 0, 0, $string, $black);

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

?>

The code above generates the following result.

Draw a character horizontally in PHP




















Home »
  PHP Tutorial »
    Image »




Color
Create
Font
Operation
Shape
Text