Thu November 20th 2008 9:39 am Blog | Gallery | Geek | Travels | Home | Contact | Archives | Links
Tux
Blog Gallery Geek Travels Home Contact Archives Links
MP3 Playlist Generator
MySQL: Get Next Auto_increment
PHP Fortune
Recurses! Foiled again....
Kernel Watch
Get yer PHP Referrers here

Geek : PHP Fortune

PHP Fortune
Monday May 13th, 2002

A simple and elegant way to provide the UNIX 'Fortune' on your web page is to use the PHP passthru function, like so:

passthru("/usr/games/fortune -s");

...or...

passthru("/usr/local/bin/fortune -s");

...depending on your distribution. The '-s' flag stands for "short", which ensures your fortunes are short and sweet, and won't screw up your page layout. However, depending on the character set you use, you might also want to put that output inside of <pre> tags, or an htmlentities() function to prevent garbage characters from displaying.

Posted by Jamie
Comments: 3
Previous EntryNext Entry

Comments: (3)

wow, great idea!!
I wish I thought of that!!
Seeing as I'm such a brilliant code-monkey
hahahahahahhaha

Posted by e-d0uble on 6/25/02 at 10:27 AM EST

oh yeah -- thanks to e-d0uble for the tip!

Posted by Jamie on 9/20/02 at 11:15 AM EST

A more platform-independant fortune-program can be found at http://aasted.org/quote/ .

Posted by DarkKnight on 11/26/04 at 4:47 AM EST


Your 2¢ (comments subject to approval)
The Captcha image Phonetic spelling (mp3)
© 2003 Jamie Doris Blog | Gallery | Geek | Travels | Home | Contact | Archives | Links