<?php
header ("Content-type: image/png");
$w = 200; $h = 100; $angle = 180;
$font_size = 12;
$text = "hello there!!!";

$image = @imagecreate ($w, $h) or die ("A problem occurred trying to create the image.");

$background_color = @imagecolorallocate ($image, 0, 0, 0); // RGB for black imagecolorallocate
$text_color = @imagecolorallocate ($image, 255, 0, 0); // RGR for red

imagefill($image, 0, 0, $background_color); // Not necessary but good form
//imagestring ($image, 4, 100, 0, 'Hello world!!!!!', $text_color);

//$font_name = "c:\\windows\\fonts\\arial.ttf";// on Windows using Wamp

$font_name = "ARIAL.TTF";
$type_space = imagettfbbox($font_size, $angle, $font_name, $text); // imagettfbbox
$x = round( ($w - ($type_space[2] - $type_space[0])) /2 );
$y = round( ($h - ($type_space[7] - $type_space[1])) /2 );

imagettftext($image, $font_size, $angle, $x, $y, $text_color, $font_name, $text); // imagettftext

imagepng($image); // imagepng
imagedestroy($image); // Destroy the image

?>