<?php
header ('Content-Type: image/png');
$im = @imagecreatetruecolor(120, 20)
or die('Cannot Initialize new GD image stream');
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
imagepng($im);
imagedestroy($im);
?>
The output is 
Now I want to know how to store this image on server
imagepng() has a second parameter which is the filename.
See
http://www.php.net/manual/en/function.imagepng.php