That's a fairly advanced topic, I bet there's a tutorial on it, but to get started you need to use some kind of graphics library, like libgd, and having true type font support via freetype installed is pretty nice too, since there are oodles of free true type fonts floating around the web.
Look up the image functions in PHP for some pointers on starting at:
www.php.net/image
After that it's just doing the math and building the graphic one piece at a time.