Apache Week
   

Copyright 1996-2005
Red Hat, Inc.

First published: 15th December 2000

Book Review: Beginning PHP4

"Beginning PHP4" published by Wrox Press serves to fill the void of books written by professionals for open-source product. PHP 4.0.0 was released in May 2000 and since then PHP, a server-side, cross-platform, HTML embedded scripting language has been growing on the popularity of the previous version, PHP 3.0

This book is written by a team of authors, namely Wankyu Choi, Allan Kent, Chris Lea, Ganesh Prasad, Chris Ullman with two contributing authors: Jon Blank and Sean Cazzell. This is not a case of "too many cooks spoil the broth" as the pool of experience tends to broaden its coverage.

It is targeted at practically anyone with HTML knowledge who is interested in developing dynamic web applications using PHP 4. It is not a prerequisite to have any computer programming knowledge at all but access to any web server and a relational database management system is a must, to fully utilise this book.

Unsurprisingly, this thick 800 page book comprises of 17 chapters and 2 appendices. Each chapter is structured nicely, starting with an introduction and ending with a summary. Examples are given under "Try It Out" sections that include a "How It Works" subsection to explain in detail what goes on behind each line of code. Users are not expected to regurgitate the code in the example but to understand them well so that they could customise it and write their own code to suit their requirements. A good way to learn a new programming language is to use this approach of learning by example.

Since it is absolutely inundated with examples, one should not read it on its own but to have hands-on sessions to implement the given code. It also frequently uses analogies and activities from day-to-day life to illustrate a concept so that they are easier to grasp. One such example explains branching statements with the decision-making required for shopping.

One must not skip the introduction chapter as it gives some basic information about PHP4 and ways to download the source code and obtain the errata and support from Wrox web site. They could as well include the evolution of PHP to PHP4 here but sadly did not.

Reinforcing the fact that PHP is a cross-platform language, Chapter 1 gives instructions for installing PHP4 with Microsoft Personal Web Server (PWS) on Windows 95/98, with Microsoft Internet Information Server (IIS) on Windows NT4 or 2000 and with the Apache Web Server on Linux/UNIX. Apache and PHP4 on Linux are installed using the Red Hat Package Manager (RPM) instead of compiling from source.

Chapters 2 to 6 cover programming fundamentals. Over these five chapters, programming concepts such as variables, data types, operations, constants, environment variables, conditional code, loops, arrays, functions and various HTML form controls are explained in relation to PHP. It also briefly explains how TCP/IP and the HTTP protocol work in layman terms. After ensuring that you are armed with enough basic programming knowledge to write a standalone web application, the book moves on to techniques for writing error handling code and debugging in chapter 7. It says that PHP does not provide its own debugger so this task has to be done manually. This is not exactly accurate, as the code for PHP's internal debugger has not been ported to PHP 4 yet but PHP 3 does have its own debugger. It should be more specific as this may give first time users the wrong impression of PHP.

HTTP session handling is the main focus of chapter 8. Examples are given on how to write your own PHP code to manage sessions or by using cookies. Compared to PHP3 that required PHPLIB, a third-party library to handle sessions, PHP 4 has greatly improved this by having native inbuilt session handling functions.

Chapter 9 explores object oriented programming and some simple classes are included. It does not delve into this subject as it admits that PHP is not a truly object-oriented language so for a complex application which really requires object-oriented techniques, they are better off using a fully-fledged object-oriented language.

File and directory manipulations are introduced in chapter 10 by going through file-related functions. In the example, a web based text editor is built. Moving on, the next three chapters talk about database by using MySQL. Steps are shown on how to install and use MySQL in conjunction with PHP.

Since XML is the current buzzword, this book includes it as well. It just grazes its surface in chapter 14. Then it devotes the next two chapters solely to handling emails and generating basic graphics using PHP. In the final chapter, it shows how the bits and pieces that have been presented in the previous chapters could be used to build a URL Directory Manager. If you do not have MySQL, appendix A provides the instructions on using an Open Database Connectivity data source instead and appendix B provides a handy list of PHP functions.

In a nutshell, this book is great for those who are interested in developing their very first dynamic web applications using PHP as it has a broad coverage and many practical examples. Programmers who are converting to PHP from another language will find this useful too but maybe a little pedantic. Experts who are well versed in PHP3 are advised to give this book a wide berth or the book may just end up in Amazon Marketplace Sellers. One used copy is already up there for sale.

Order now at Amazon.com 


This feature brought to you by: Min Min Tsan
Comments or criticisms? Please email us at editors@apacheweek.com