Learning PHP the Fun Way

A friend of D. Keith Robinson made up a MadLib for Keith’s birthday the other day and asked him to post it on his website and start a “meme.” It looked fun to me, but all of the fill-in-the-blanks were embedded right in the story, so it was missing that element of goofy surprise that I remember about the MadLibs I did as a kid.

PHP for the World Wide Web

As it turns out, this MadLib presented just the opportunity I needed to try to write my first PHP script. Even though I had bought PHP for the World Wide Web: Visual Quickstart Guide months ago to learn how to do some rudimentary programming, I never got around to actually using it—probably because I didn’t have a compelling reason to do so. It’s usually a lot easier to learn things when the lessons can be applied immediately—especially when it comes to languages, whether they be human or computer.

Anyway, the script is really simple, but I suppose I need to start somewhere. It pulls values that have been entered into a form and inserts them into a story. When fields are left blank, it inserts default values. With the help of a friend, I also managed to get it to properly use “a” or “an” in most cases, except when the following word begins with some consonant-sounding vowel, such as “eulogy” or “urinal.”

So, check out the Typical Day MadLib Generator and play around with it a bit and let me know what you think.

This entry was posted in technology. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

5 Responses to Learning PHP the Fun Way

  1. Karl…might I heartily recommend another great PHP book? It’s
    called Building a Database Driven Web Site with PHP and MySQL and you
    can find it here.

    I also recommend http://www.sitepoint.com (the publishers of the book) for their many wonderful articles and tutorials on PHP, CSS, Javascript, etc. Happy coding!

  2. Karl says:

    Thanks for the recommendations, Michael! I’ll be sure to check out both the book and the site.

  3. Dad says:

    Well, I did it and it was mildly amusing, but my “no job” and “still no job” (for example) didn’t do the story line any good. Maybe more explicit groundrules, like “use only one-word answers” would help defuse loose cannons like me.

  4. Karl says:

    Well done, Sarah! I especially like the part about the “quick jaunt to calvin college to wink with Jeff, who’s a total fairy princess.” :)

    Dad, thanks for the suggestion. It’s hard to predict those sorts of variables until people have played around with it.

Leave a Reply to Sarah G Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:
<a href="" title=""> <b> <blockquote cite=""> <code> <em> <i> <s> <strike> <strong> <div align="" class="" dir="" id="" lang="" style="" xml:lang=""> <param name="" value=""> <pre style="" name="" class="" lang="" width="">