Google Command Line Calculator

In a somewhat shocking move, my Google Command Line Calculator hack was picked up for the second edition of Google Hacks.

I found this out from Rael back in October at Web 2.0, but I forgot to blog about it. I finally picked up a copy when I crashed the O’Reilly booth at MacWorld. Sure enough, I am Hack #47: Bring the Google Calculator to the Command Line.

I know hard core Unix weenies use bc and dc, but I don’t want to bother with the reverse-polish, thank you very much. Besides, Google supports a variety of non-standard features, like unit conversion, roman numerals, and physical constants.

In exchange for contributing my hack, I receive fame, glory, my bio at the front of the book, and blogging rights.

Programming eBay Web Services with PHP 5 and Services_Ebay

My latest article is now available on the O’Reilly Network. "Programming eBay Web Services with PHP 5 and Services_Ebay" provides an introduction to eBay Web services and Stephan Schmidt’s awesome PEAR package, Services_Ebay.

As I’ve blogged before, Services_Ebay is a PHP 5-only module that makes it drop dead simple to interact with eBay Web services. This piece walks you through getting started with Services_Ebay, shows you how to search the eBay listing database, and then displays the found items in a variety of ways.

As a extra special bonus, I highlight all the cool behind-the-scenes PHP 5 magic that’s taking place. I also do some nifty stuff by overriding Stephan’s model classes to provide an alternative data view. I’m sure this will lead to nasty comments from the peanut gallery about my lack of respect for MVC.

Writing for PHP 4 and PHP 5

A few weeks ago, John Lim kindly reviewed Upgrading to PHP 5. Overall, I was very happy with his comments, particularly when he said:

Even though I have read widely about PHP5, I still found this book a useful reference, because it delves deeper into the new features than most articles I have seen.

There’s a lot of free PHP 5 material, and I was a little worried that people wouldn’t find anything new in the book. It’s a good sign if John, who reads widely on PHP 5, learns something.

He also had one critique: that I didn’t spend enough time covering how to port code from PHP 4 to PHP 5. At first, this surprised me, as I specifically provide both PHP 4 and PHP 5 code examples.

Then I realized our PHP migration experiences are totally different. When I moved to a new version (and I’ve made many, as I started PHP programming with PHP/FI, aka PHP 2), I ported internal applications. I didn’t worry about other people running my code.

In contrast, John writes ADODB. This is an external application. He’s not writing for his personal or corporate use. He’s writing for everyone and anyone.

I could control my environment. While I know people would be running under shared hosts, I figured they could at least control whether they’re using PHP 4 or PHP 5.

John, however, doesn’t have that luxury. He needs to write code that can run under both PHP 4 and PHP 5. That’s why he wants me to discuss “features such as PHP_VERSION, phpversion(), extension_loaded(), function_exists(). I don’t cover that at all.

If you need these this, I guess you’ll have to wait for the second edition. :) However, I think if I was in this situation, I’d create a separate PHP 5 branch. There are so many PHP 5 specific features that just don’t play well with PHP 4, and I wouldn’t want to limit myself.

I’m interesting in hearing what other people are doing. I’ve only been following the PEAR folks a little bit. How has this been playing out?


My follow-up piece, on PHP and REST, is now available on ONLamp.Com.