While it is possible to draw a happy face using the graphics methods in PHP, that would be a tremendous waste of computing power and a very time consuming way to draw a picture. The graphics methods are valuable for one primary purpose: to create graphs and charts on the fly. Look at image functions in the PHP manual.
Instead of having a link to an image refer to a jpg file or some other picture format, it refers to a php page that generates the image:
<img src="/php-mysql/graphics/graph2.php" />
Example 1: A simple image showing a few methods. text of example1, text of graph2.php
Example 2: A bar graph text of example2, text of image
Example 3: A PIE graph text of example3, text of image