Richard Parnaby-King

Web Developer – PHP, Zend Framework and Actionscript 3

Posted on | | No Comments

Nearly every forum allows it’s users to have a signature, somewhere the user can post a link to their personal or favourite website as well as quotes and images. This post will go through the steps of combining these last two so that every time the image is reloaded, a random quote is placed onto an image.

 Preview

Random Quote from an image generated with PHP

The Code

[php]
php.net website

Extra Credit

In this simple example we have only created a white rectangle image and put text on it. There is no reason why this code cannot be expanded to allow text to be placed on any image. You could have, for example, an image of a little man holding a very big sign, then use this script to place the random quotes into the sign.

Most (of the good) forums have filters when you try to add an image from URL, throwing a wobbly when you try to upload a file that does not end in .png, .jpg or .gif. To get around this, use an .htaccess rewrite rule similar to the one below:
[c]
RewriteEngine ON
RewriteRule random-quote-image.png$ random-quote-image.php [L]
[/c]

Very simply, this will route any requests for ‘random-quote-image.png’ into the php script.

Posted By:

Comments

  • ABOUT

    Having fifteen years of programming experience in PHP, Zend Framework and ActionScript3, I have a very strong working knowledge of object orientated programming.

    I am a PC Gamer! Playing FPS, RTS, RPG and the occasional MMO since 1996 I have a huge number of a variety of fast-paced games.

  • Recent Posts

  • Categories

  • RSS SUBSCRIBE TO OUR FEED