Working with Text

In this section we will work primarily with PHP’s TrueType functions, which are useful for creating sophisticated charts or navigation. For a quick and easy way of writing to an image, however, the imagestring() function is the perfect tool.

Writing to an Image with the imagestring() Function

The imagestring() function is simple and useful. It requires an image resource, a font number, an x-axis location, and a y-axis location (with location 0,0 being the upper-left corner of the image). The function also requires the string you want to output and a color resource. Of these arguments, only the font numbers should need much explanation. These are built-in fonts of ascending size. Font 1 is the smallest in size, font 2 is slightly ...

Get Sams Teach Yourself PHP in 24 Hours, Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.