Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Overview

Get past all the hype about PHP and dig into the real power of the language. PHP: The Good Parts gives you look at the most useful features of PHP, and explains how you can speed up the web development process with them. You'll learn why the most commonly used PHP features are often misused or misapplied, and which features add strength to object-oriented programming. You'll also focus on aspects that will help you integrate your application with databases.

Subscriber Reviews

Average Rating: 1.6666666666666667 out of 5 rating Based on 6 Ratings

"Maybe PHP just doesn't have good parts?" - by Anonymous on 30-JAN-2013
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
I'm coming to this as a long time perl/python web developer--I've had to hack at wordpress a few times, but mostly stayed away from PHP.

Now I've got to dive into some WP theme internals for a client, and I wanted a real fast overview of syntax and a sense of what "good" PHP might look like if I happened to see it.

The book starts off with some promise, goes through the basic things I expect to see like data types, control flow, and how PHP integrates with HTML in a dynamic document. Then it gets to functions / strings / arrays / objects and things go well and truly out of the realm of "the good parts."

Those chapters (3 through 6) are basically a foreshortened "php for beginners," without explaining why any of the constructs mentioned (in the incomplete function references given) might be considered optimal, or better than some other way of doing work. Partly I suspect that this is because PHP doesn't have a great set of built-ins but still, if you're going to start out in the mold of "JavaScript: the Good Parts", try to do it some justice.

It's worth calling out the Objects chapter (6) in particular for being not only a bad representation of PHP, but a clear primer on how not to do OOP in _any_ language. The classes that are given as examples are excuses for using string concatenation to bodge giant chunks of HTML together and then echo it. There's no modularity, no separation of concerns, no useful discussion of inheritance. My notes from this chapter trail off after the point where I wrote "More terrible code here."

Chapter 7 briefly talks about MySQLi and PDO, but again doesn't touch on why either of those might be "good" or not. Additionally, the author chooses to gloss over security by "keeping things simple," which means the examples given pass interpolated strings directly from $_POST into a $mydbhandle->query() call.  Exposing any code to injection attacks that recklessly is essentially developer malpractice, and I kind of can't believe the editors let that go to press.

From there I was reading in a bit of a haze, so I'll admit to skimming some--the other things I happened to notice were:

* All discussion of filesystem access methods was wedged into the chapter on database interaction (huh?), and again, no discussion was given of whether you'd consider those 'good' or...'bad'?  I have no idea what the author's opinion is on filesystem access, which you'd think would be important for a web facing language--but then, if they're willing to let people POST right into their db handle, who knows what they open their filesystem to.

* Regular expressions were relegated to the chapter on "Advanced goodness," on a level with XML parsing and a survey of available IDEs.  Regex is kind of a core feature of a language that does as much string parsing as PHP seems to, so why is it a half-realized note at the end of the book?

I can't recommend this book. EOM.

Report as Inappropriate

"Dont Bother" - by Anonymous on 25-APR-2012
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
There is a chapter called Strings, with a section called "What is a String?".  

Don't waste your time.

Report as Inappropriate

"Php - the Good Parts" - by newbie on 18-APR-2010
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
I like the style of this book - so I was initially going to give it a high rating; however I have found errors in the tutorial code - last example:  Traversing Arrays - Chapter 5
the Unset function should have a closing bracket after it

Report as Inappropriate

"Nothing like Crockford's book" - by wleftwich on 17-APR-2010
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
I picked up this book based on the title, assuming it would be similar to Douglas Crockford's "Javascript: The Good Parts" -- an advanced book with the theme that inside the ugly language there is a decent one that you can use by ignoring certain functions and statements and following certain coding patterns.

This would be useful to experienced programmers who have to work in PHP, and want to make the best of it.

Disappointingly, this is a basic text and written from the point of view that PHP is really pretty great.

If you're looking for an advanced PHP book, I recommend "PHP in Action".



Report as Inappropriate

Table of Contents

 

Extras

The publisher has provided additional content related to this title.


Description
Content

Visit the catalog page for PHP: The Good Parts

  • Catalog Page

Visit the errata page for PHP: The Good Parts

  • Errata

Download the supplemental electronic content for PHP: The Good Parts

  • Supplemental Content