Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
PHP Books Media Programming Book Reviews

PHP Developer's Cookbook

Reader LetterJ preheated his brain, stirred in some acronyms, and sent in his review of The PHP Developer's Cookbook, which sounds like a more-than-usually-useful guide to solving specific programming problems. This "cookbook" approach is one I'd like to see in more books, too.

The PHP Developer's Cookbook
author Sterling Hughes, Andrei Zmievski
pages 528
publisher MacMillan Publishing Company
rating 9
reviewer LetterJ
ISBN 0672319241
summary A problem/solution focused guide to PHP programming that's neither condescending nor off-limits to mortals -- just right for intermediates

*

Escaping the remedial classes

PHP books are starting to come of age. 12-18 months ago, if you wanted a book on PHP, it was as though Henry Ford was in charge of author outlines. "You can have any PHP book you want as long as it assumes you've never heard of PHP and have never done web development." Every single book, it seemed, started by explaining dynamic web sites and why you'd want to build them. It would follow with an evangelizing of PHP as a solution and lead you through a few sparse examples and leave you to your own devices. This was great (since most folks using PHP were beginners), but it left a crowd of advanced beginning and intermediate PHP programmers milling about on discussion boards and mailing lists, clueless as to how to combine the examples in the books into cohesive web applications.

Things are looking up, though: Several books released in the last 6-12 months have started to give those people some direction, including the recently published PHP Developer's Cookbook, by Sterling Hughes and Andrei Zmievski.

What's a Cookbook?

Any book that calls itself a cookbook should meet a few basic requirements. In the kitchen, a cookbook provides people (who aren't gourmet chefs) with detailed instructions on how to make specific dishes. At the same time the cookbook can't assume you're an idiot. You have to know how to use a knife, pans, etc. in a basic way so that the explanations of new ways to use the tools will make sense.

This book uses that exact approach. Many of the entries would seem obvious to a seasoned programmer who is switching over to PHP from some other procedural language. At the same time, it assumes you have a functioning PHP environment and that you have a grasp of the basics of the language. Each entry solves a specific programming problem in one or more ways. When more than one way is presented, the authors also provide reasons a programmer might choose one over the other. This problem-solving orientation helps out programmers who know what they need to do, but don't know what functions to look up in the official manual.

What's Included?

The book is broken into 5 parts, 4 of which will be useful to most readers:

  1. Language Constructions and Techniques
  2. Databases
  3. Going Outside PHP
  4. Generating Other Languages
  5. Zend API
Part 5 focuses on building your own PHP level functions and extensions to the language. As such, it seems a bit out of place for a book that seems targeted to advanced beginners and intermediate PHP programmers. However, the section is only 35 pages and comes at the end of the book, so it won't overwhelm readers and can easily be ignored if you have no need to extend the language.

Part 1 is by far the largest portion of the book and provides the meat and basic ingredients to more elaborate programs. It covers strings, numbers, dates and times, arrays, associative arrays, regular expressions, file access, file contents, directories, functions, classes, sessions, automation and built-in constants.

At first glance, this table of contents concerned me. After all, that's pretty much the way that most language references are organized and when you aren't exactly sure what tools you need to do something, that can be hard to follow. For example, imagine you want to output the results of your script to a file. However, you want to make sure you don't overwrite an existing file. You could wander through the file functions in the regular manual and discover that there is a file_exists() function. However, if you have this book, you could look up "Testing Whether a File Exists" which phrases your situation as a problem, "You want to know whether a file exists before you try to perform any operations involving it." This straightforward approach helps you choose the appropriate method for doing something and can occasionally prevent you from misusing a function as in the "everything looks like a nail" paradigm that new programmers get into when they find a new function.

Parts 2-4 work their way through database abstraction, COM and Java objects, IMAP email, LDAP, network communication, image creation with GD, and XML documents and transformations.

What's Good?

Well, as I've pounded into the ground, the problem/solution organization of this book is it's biggest asset. When I go to a book for information, I'm looking because I'm having a problem of some sort. The information is presented clearly and the design and layout of the book is pleasant with enough whitespace around the examples to take notes. The book isn't filled with wasteful screenshots of browsers containing forms. In fact, I just flipped through it and can only find one diagram of any sort. The book focuses on the code examples and explaining them.

What's to Consider?

At first, a list price of $39.99 may seem high to some folks for a 500 page book, particularly with books like WROX's PHP books next to it on the shelf at twice the thickness. However, this book doesn't try to fill pages for the sake of filling pages. I'm glad there are no wasted screenshots in this book or 125 page HTML tag references. If the publisher had wanted to, this book could have been much bigger with no real extra content.

The only other thing that concerns me is the potential for people outside the target audience to buy this book and be disappointed. If you are a novice programmer looking to learn PHP, but haven't explored functions or dynamic web applications, this book is not for you -- yet. Similarly, if it is blatantly obvious how you would step through a directory full of files and make changes to each, this book my not have any useful information in it for you. It's aimed squarely at the middle ground. Given the glut of books aimed at beginners and the experts able to read the PHP sourcecode, that's a pretty good place to be. The inclusion of Part 5 is a slight mark against it, but definitely not a showstopper

Summary

If you are using PHP to develop anything more than a simple one-page script, you are going to run into more than one of the problems presented in this book. In fact, there's a pretty good chance that your application will be a series of the problems presented in this book. You can either pick up this Cookbook and get on with your coding, or bug everyone and their brother on the discussion boards to build your algorithms for you.


You can purchase this book at ThinkGeek.

This discussion has been archived. No new comments can be posted.

Book Review: PHP Developer's Cookbook

Comments Filter:

Thus spake the master programmer: "After three days without programming, life becomes meaningless." -- Geoffrey James, "The Tao of Programming"

Working...