8 comments | Posted: 15 February 07 in Books, by Nathan Smith
I recently read PHP Solutions by David Powers, and have to say it has been one of the better ones I’ve come across in awhile – definitely one I will keep within reach. I think the best way to describe it is to use an analogy. What CSS Mastery is for CSS, PHP Solutions is for PHP. This book is full of practical PHP tips and tricks that can help you hit the ground running. It takes a learn-by-doing approach.
While this isn’t a comprehensive how-to guide covering OOP, it does approach things with a future-proofing mindset. Powers is careful to point out where things are specific to PHP 5, and gives alternatives to making them work in version 4. He also talks about what features will be prevalent in PHP 6, such as PDO becoming the more standardized way to handle database connectivity.
The first few chapters start off with the basics, showing PHP syntax and explaining how to build dynamic templates using includes. He also shows how to protect includes from being accessed independently of their accompanying pages, storing them separately from publicly accessible directories. He also shows how to build a file-upload interface for use in a basic CMS.
He then goes on to build a photo blog, complete with auto-generated thumbnails. One cool solution he uses is checking the width of an image, and then using that numerical value to set the width of a paragraph which contains explanatory text. By constraining the width, it keeps the line of text from being longer than the image is wide. He also shows how to use PHP’s date output to keep the copyright for your site on-par with the current year.
There were only a few qualms I had with some of the client-side coding conventions. In some of his
<form> examples, he had the name attribute, which is deprecated in XHTML 1.0 Strict. Such details are not terribly important, but are still worth noting. He also had a few empty
<td></td> (table data cells) and superfluous
<p> </p> placeholders for controlling page layout which weren’t exactly semantic. However, for a book dealing with a server-side language, the client-side code examples were a lot better than most!
The latter part of the book gets into more advanced topics such as user management, remember sessions with cookies, and handling database security. By the time you complete this book, you will have the know-how to create a light-weight content management system that will uniquely fit your needs.
I really like that PHP Solutions takes you through the process of creating a dynamic site from start to finish, unlike many books which contain a slew of disparate examples. I would unreservedly recommend it to anyone looking to get into PHP. For another opinion, read the book review by Jonathan Snook, freelance web developer and member of the CakePHP documentation team.
Discuss This Topic
Comments closed after 2 weeks.