I need some help about PHP GD. Here is my piece of code.
header("Content-type: image/gif");
$image = imagecreatetruecolor(550, 20);
imagealphablending($image, false);
$col=imagecolorallocatealpha($image,255,255,255,127);
$black = imagecolorallocate($image, 0, 0, 0);
imagefilledrectangle($image,0,0,550,20,$col);
imagealphablending($image, true);
$font_path = 'font/arial.ttf';
imagettftext($image, 9, 0, 16, 13, $black, $font_path, $lastlisten);
imagesavealpha($image, true);
imagepng($image);
The problem is when I use imagepng, it can show the png just fine like this. 
But if I use imagegif instead, it will become this.

I did tried using different header for gif and png. The result for imagegif is still the same.
The question is how do I make in order to display GIF version properly? Thanks you
First problem : your characters are ugly: that’s because you need to set a palette with less colors when using imagecreatetruecolor.
should solve this problem.
Second problem : there is no transparency.
As you can see on PHP manual,
This function does not work with GIF files.
You can use imagecolortransparent instead but this will not be perfect because fonts has anti-aliasing to make their border sweeter.
Here is my code:
Result here
Hope this helps.