PHP Cookbook - Solutions and Examples for PHP Programmers
Sklar, David & Trachtenberg, Adam
O'Reilly and Associates
ISBN 1-56592-681-1
reviewed by Ryan Gantt

First of all, for anyone who doesn't know what PHP is, or what sets
it apart from Perl or Python, here is a short introduction: If you
come from a Perl background, you might relate PHP to maybe Perl using
Mason. If you are coming from Python for CGI, you might think of PHP
as Python with easier access to http variables, and without required
use of a cgi-bin. As http://www.php.net puts it, "PHP is a widely-used
general-purpose scripting language that is especially suited for Web
development and can be embedded into HTML." If that doesn't just about
sum it up, then I suggest you do some surfing around PHP.net, because
the true meaning of PHP is beyond the scope of this review (shameless
reference to a comment in the next paragraph).

Second of all, I would like to define what I feel is a good book. A
good book is one that is worth it's weight in gold, a book that get's
it's edges worn, and it's binding marred by excessive overuse, a book
that you see your friend carrying down the street, even though you know
for a fact that he's read it a million times. I think that for a book
to be useful, it *must* not spoon-feed information, it must not make
allusions to "key" concepts and then say something along the lines of,
"but this concept is beyond the scope of this book," and then allude
to it several more times, even on the same page. If there going to
talk about something, they better make it understandable, because I
don't ever remember hearing about book reading prerequisites. A good
book must give examples to show their meaning, and even in some cases,
apply that information to a common problem.

PHP Cookbook is a good book. This is one of the most intriguing books
I've had the chance to read, because of it's odd nature. It contains all
of the qualities of a reference book, while maintaining a small learning curve
for those who maybe aren't as 'into' PHP as the author. As a recipe book it 
is laid out by 'locale origin', the PHP Cookbook is laid out by
concepts, such as xml, or databases, and then ordered into 'recipies'
that build off of that base concept, and concepts that have been presented
in the previous chapters. No allusions are made that can't be referenced
back to an earlier point in the book, and even if you have no clue what
the recipe is talking about or 'calling for', you rarely finish reading
it with a defeated "hoomph" or a quick scratch to the head.

The first half of the book is focused on giving easy-to-use,
easy-to-apply solutions for everyday (easy-to-solve) PHP problems. After
reading some of the solutions, I get the feeling that one or both of
the authors has spent many hours scanning PHP forums and mailing list
archives to seek out common problems, and incorporate solutions to many
of those problems into the book. One of the most concise solutions in the
book includes a completely, 100% hands free automated Calendar script,
which I'm sure has been/will be utilized by the many of the books' readers. He
takes PHP's broad and often dull time functions, and zips them together
to create an excellent script.

The final half of the book focuses on PHP's more advanced, and less
used concepts. Client-Scripting for PHP-GTK? This is a really neat
concept, which is hardly mentioned (in depth) in many PHP books,
but is covered broadly in the Cookbook. Other concepts include XML,
HTTP-Request, XML-RTC, Regular Expressions, and Class/OO Programming
in PHP (the author makes it clear that Object Oriented (OO) 
will be improved in PHP 5, because of Zend's new engine, which shows 
that the authors really care about getting their information correct, 
and preparing their readers for eminent (and massively huge) changes).

One thing that I found odd was the fact that the author of this book has
this really almost 'odd' obsession with the Pear libraries (definitely
not a bad thing), and he tends to call them for his examples more often
than he ought to. The Pear libraries are good, but sometimes PHP has
built-in functions that can do the same tasks (althought perhaps with
somewhat less customization) in far less steps. For the beginner or even
intermediate coder, this may seem unnatural and even confusing at times,
since Pear was only recently taken out of it's baby beta stages, and is
generally not even mentioned in PHP tutorial books, and sometimes not
even in reference books (heaven forbid). The last chapter of the book
(one of the longest) focuses mainly on Pear's application and distribution
throughout your scripts. He introduces Pear's database abstraction and
error-handling, and many other underutilized concepts in surprising
depth. He just makes it look so darn easy. =]

As far as experience goes, I would definitely recommend this book
only to someone who has done substantially more than a "hello world"
script with PHP. Although clear, concise, and down-to-the-point, this
book could prove overwhelming for someone new to programming. However,
judging from the concepts laid out in the book, I'm sure that anyone
with reasonable amounts of previous CGI or almost any kind of programming
would have less or perhaps no trouble with it. What this book *isn't*
is a regurgitation of the online documentation. The author seems to
make sure of that, by implementing concepts not even found in the
documentation. Altough sometimes the best reference is to be had at
http://www.php.net/FUNCTION_NAME, but even PHP's own documentation falls
short at times.

Although this book is severely and painfully excellent, and I will no
doubt buy the second, third, fourth and all editions thereafter, there is
one large quirk that I have with the book; lack of a function reference.
There is no function reference in this book. I looked all over the back
for it, and in the front, and all locations between, and it's nowhere to
be found. Alright, I will admit that probably every single function in
the PHP library is used, explained, and applied somewhere in the book,
and you can just look up the name of the function in the index, but what
if you don't know the name of the function? A good clean function list
ordered by category is what I longed for most when reading this book. Oh
well, even without the function reference, this is definately one of my
top 5 all-time favorite books (it's third only to The Lord of the Rings,
and Tom Clancy's Net Force =]... that has to say something about quality,
if nothing else in this review).

On a final note: this is the most PHP you'll ever find for $39.95,
unless you like arguing with disgruntled Perl hackers on PHP.net's
function reference comments. =]