Book Review: PHP 5 in Practice

Disclaimer: I have quite a few disclaimers this time around… First of all, I happen to know one of the authors – Eli White. We've run into each other at a number of conferences, had a few beers together, and I've even been over to his house to play cards. I happen to like the guy and although I read the book and formed my opinions first, feel free to take it with a block of salt. Second, I didn't purchase this book. I won it as part of a charity auction at ZendCon last fall. That said, would I buy the book again? Read on…

Title: PHP 5 in Practice
Authors: Elliot White III and Johnathan D. Eisenhamer

First of, this book weighs in at a bit over 400 pages which puts it on par with most of the other PHP books out there. It covers the standard topics of Strings, Times and Dates, Arrays, Classes and Objects, Sessions, and everything else we've come to know and love in PHP and in the various PHP books… but this is where it diverges.

The Good

First, they skip over most of the "conventions of this book" stuff. Most of us in this space understand that monospace font means source code. These two immediately dive into the coding standards (PEAR), how they're utilized, where they are/aren't utilized, and why they are/aren't utilized. Even if you disagree with their reasoning – and I think PEAR has a bit of room for improvement – understanding it gives you an idea of what to expect. One of the first habits I picked up from this section was simply denoting my variables with {}'s, especially in quoted strings. It is a tiny habit change but immediately resulted in more readable and clearer code. Also, since PHP is greedy in its variable interpretation, it simplified the quote structure of many of my strings.

Second, the most amazing – yet not immediately noticable – aspects of this book is the way it begins. Unfortunately, I've gotten used to the numerous "advanced" PHP books that begin with a description of Strings. And then they describe what an Array is. If you're lucky, they even tell you how to connect to a database! No, I'm not kidding. I understand the need to appeal to newbies, but come on… I know what strlen does! Anyway, back on point… this book doesn't completely strike those sections, instead it starts every single chapter with a "Quick Hits" section. The authors use this space to list a bunch of common operations and give a sentence or two on each of them.

Finally, as a result of these Quick Hits, the authors can dive into interesting concepts and functionality quite quickly. It doesn't quite read like one of O'Reilly's cookbooks, but it approaches many of the sections from the same direction: "Here's our goal, let's make it happen."

The Bad

This book is not for newbies. If you're considering picking up PHP and want to "see what it's like", this isn't the book for you. For this book to be anything more than a paperweight, you need to have a working knowledge of PHP and preferably some tasks to complete. It's not a general reference manual like Christian Wenz's PHP Phrasebook but could work as one if you're trying to remember the order of $haystack and $needle yet again.

The Ugly

In the Slashdot review, the reviewer picks on the fact that there are no screenshots or representations of the output. I'm in full agreement on this one… for many of the completely text things, okay it makes sense. Unfortunately, when you have a whole chapter dedicated to the GD image library (Ch 18, pg 359), it's ridiculous not to show images. Code is great but sometimes you need just a bit more.

Summary

Okay, so there are a few weaknesses, but honestly I've had trouble figuring out other bad things to say. I appreciate the fact it starts from the premise that advanced PHP developers probably understand Arrays. Unfortunately, the lack of output seems a bit silly and even detrimental at times. The content is top notch but this is such a glaring issues, that I can't give this one higher than an 8.5. Fortunately, I think the addition of images to Chapter 18 and displaying the output on some of the more complex snippets would easily give this one a solid 10. If there's a second edition, I hope the authors and their editors take this one into account. And yes, I would buy this one again.