Programming PHP - review

by James A J Wilson on 2 January 2007 , last updated

Archived This page has been archived. Its content will not be updated. Further details of our archive policy.

Introduction

  • Authors: Rasmus Lerdorf, Kevin Tatore, and Peter MacIntyre
  • Publisher: O’Reilly
  • Year: 2006 (second edition)
  • ISBN: 0-596-00681-0

Programming PHP is a practical guide to the open source PHP programming language. PHP is predominantly used as a server-side scripting language for Web applications. This means that it can dynamically respond to user inputs on one Web page and return various different customised Web pages to that user, according to what they have entered or what browser settings they are using. PHP is particularly useful for websites that interact with behind-the-scenes databases. The popular online retail site, Amazon.com, is an example of a Web application built using PHP. PHP is regarded as being a relatively straightforward language to learn, whilst offering plenty of sophisticated functionality to the programmer looking to get things up and running quickly.

The book is co-authored by Rasmus Lerdorf, the original creator of the PHP language, giving it a certain authority over its rivals. Whilst it is not without its faults, Programming PHP provides a thorough overview of the language and should prove useful to programmers at an improving or intermediate level.

Is this book for me?

I came to this book with some rudimentary knowledge of PHP, and a vague recollection of other programming languages learned in my misspent youth. This was a definite advantage when reading Programming PHP, as I already understood most of the concepts and many of the commands discussed therein. Even so, I did get a bit lost at times.

The book is divided into chapters, each covering a particular aspect of the language, and doing so quite comprehensively. Even the chapter on language basics goes into quite sophisticated techniques for using variable variables and other areas that are unlikely to be required by beginners designing simple websites. The chapter on objects, for instance, despite its clear introduction, may well scare off readers without some prior grasp of the concept. The learning curve in each chapter is steep. I had to read some passages several times, and terminology has a tendency to creep in before any explanation of it has been given, e.g.

: Interfaces provide a way for defining contracts to which a class adheres; the interface method prototypes and constants, and any class which implements the interface must provide implementations for all methods in the interface.

I’d say that if you can understand a passage such as this first time, you’ll stand a better chance with the book. Having said this, simple concepts and commands are dealt with in a simpler manner. Most are accompanied by short chunks of code that both work and illustrate correct syntax helpfully and succinctly. The authors of Programming PHP declare only one assumption about the reader, that they have a working knowledge of HTML, but I would suggest that a reader would benefit from a little experience in other programming languages before diving in.

One clue as to the book’s intended audience level is the assumption that the user will be working on a Linux platform rather than Windows. The concluding chapter does, however, explain how to configure PHP on a Windows machine.

How should the book be used?

One of the things that slightly confused me when I started reading Programming PHP was how it was intended to be used. I’ve read books that are clearly targeted at the teach yourself market, and those that clearly exist as a reference guide. This initially seemed to belong to the former category, beginning as it does with a guide to installing PHP and then progressing to the basics, but after further reading I’d say it is perhaps of more use as a guide to dip in to once the basics have been grasped.

It is by no means impossible to read the book in a linear fashion, but the way in which each chapter progresses to the most detailed technicalities of a particular topic before going back to basics on a different topic at the start of the next chapter is not ideal for some types of reader.

The first appendix to the book lists most of the standard PHP commands with a brief synopsis of their use. In practice, the book might prove most helpful when referring to this, and using the standard chapters when requiring more in-depth information about syntax and usage.

The individual chapters are likely to prove helpful to PHP programmers engaging with aspects of PHP that they were not previously familiar with. The chapters on graphics (the GD extension), PDFs, and XML are of particular note in this respect.

What does the book cover?

The real strength of Programming PHP is its comprehensiveness combined with its succinctness. It covers a wide range of topics without wasting words. Its examples are often clearer and less obfuscated with comment than those available on the official php.net website, concentrating as they do on probable real-life use whilst not neglecting the occasional hint for creating elegant code.

The authors have also been diligent to ensure the book is up to date (at the time of writing). The book covers PHP 5, and even includes features that were known about but not fully implemented whilst it was being written, such as PHP data objects (PDO).

There are chapters on application techniques, extending PHP, and security measures, as well as those on graphics, PDFs and XML. The chapter on security is particularly recommended, offering straightforward advice on how to avoid the common programming pratfalls beginners are liable to make.

Conclusions

Whilst I would not recommend this book to a complete programming novice, it provides a good guide and reference source for those at an improving level. I personally found it useful and shall be referring to it myself when next let loose on some PHP code. An additional plus was that it introduced me to some new issues and commands that I would have been unlikely to find out about otherwise, as I would not have thought to search the official website for them.

Perhaps in the next edition the authors might consider explaining new concepts and commands when they are first mentioned, but this should not detract too much from the book’s strengths.

OSS Watch has a range of briefing notes for software developers.

Further reading

Links:

Related information from OSS Watch: