Sklar and Trachtenberg, PHP Cookbook (3rd ed., 2014)

Sklar and Trachtenberg’s PHP Cookbook is a difficult book to review; the book is clearly written with at least two different audiences in mind, and this means that parts of the book vary in sophistication and depth. On the one hand, the book is intended in part to complement Sklar’s (2004!) Learning PHP 5, to serve as a second book for PHP novices, to cover some of the many topics that book’s “PHP with training wheels” approach did not. On the other hand, the book is intended for readers who are familiar with the basics of the language who want to learn how to do things well in PHP.

For the beginner, for example, Chap. 6 begins with an introduction to functions, and Chap. 7 on objects likewise begins with a very gentle introduction to objects; Chap. 1 covers the basics of working with substrings, and Chap. 18 introduces some issues in PHP security. However, beginners might be better served by reading the relevant sections in Tatroe et al.’s 2013 Programming PHP. Both cover much of the same ground, but I find Programming‘s coverage to be clearer and in greater depth.

This book also does a lot of what it says on the tin by providing a reference for a lot of situations you might run into when programming PHP. Need to work with email? Drop in some regular expressions? Mess around with an object using array syntax? (Look at 4.25 for the latter– a nice trick.) I personally don’t spend all of my time in PHP, and it’s nice to have code snippets at hand when you need them.

More than these individual recipes, the value of the book to my mind lies in the sections for the programmer who realizes that there are different ways to tackle a particular problem in PHP. PHP comes with a heap of built-in functions (some of which are redundant); these functions are further complemented by libraries, packages, and software that extend and supplement the core of PHP. A lot of PHP programming is simply coming to terms with all of these competing ways to do things, and this is one of the strengths of the Cookbook. Sklar and Trachtenberg often tell you which function to use, and why (though some parts simply list different possibilities without much differentiation). To pick an example at random, (*rimshot*) they explain why the (built-in) mt_rand() function is better than the (built-in) rand() function for generating random numbers within a particular range. This is not something Programming PHP is always good at, actually, and its function reference simply lists all of the functions without explaining differences between them ( can often be helpful in this regard, too).

It limits the usefulness of the book, however, that you have to go digging for these sections, that you don’t know in advance whether the recipe you’re interested in is a brief or introductory discussion for the beginning user or a helpful guide through the PHP wilds. In some ways, this book is like the maps nature parks often give out to tourists: some parts only give you a vague idea, while other parts of the map can be a reliable guide to the terrain. Sklar and Trachtenberg’s PHP Cookbook can still help you to get around, but it’s a good idea to keep your wits about you, and to make use of other resources, as well.


Korpela, Unicode Explained (O’Reilly, 2006)

Korpela’s Unicode Explained was originally intended for three audiences, I think. The first was the casual user who might need to make some basic use of Unicode in everyday life (entering a little bit of Unicode in Windows, for example). The second was the advanced user who might need to draw on some Unicode wizardry in a few specialized cases: programming, HTML or other markup, or the internet. The final audience is those wanting an introduction to the principles behind Unicode without making a brute force attack on the Unicode Standard itself. The passage of time means that the book may now be less useful for either casual users or advanced users (who really do need current information). Nevertheless, Korpela’s work remains helpful, and his discussion of the theoretical side of Unicode is excellent, both clear and nuanced.

Major changes have happened in the Unicode world since this book was written. Characters and scripts have been added of course, but the real difference is that Unicode support is much more pervasive than it was when the book was written. Unicode is much, much more common on web sites now, Emacs 24 finally has long-overdue support for certain Unicode features such as bidi text (though vim is still a holdout in this case), and most programming languages have come to adopt Unicode as fundamental to the way that strings work (such as the adoption of Unicode in Python 3).

Very many of these changes occurred after the 2006 publication date of Korpela’s book, and this means that at points the book reads like a period piece– the changes were in the foreseeable future, but not there yet. This also means that some parts of the book are very out of date. The section on Perl, for example, is completely out of date: however sluggish it may have seemed in 2006, Perl has now adopted Unicode to such an extent that it’s even changed some of the fundamental ways Perl works. Long-beloved character class shortcuts speak Unicode now, which means it’s often less trouble to just use full character classes. (For more on Unicode in Perl, check out the relevant sections in the llama and– if you’re brave of heart– in the camel.)

Much of the utility of a book like this is expert discussion of such advanced topics; having to check the book’s information against more recent sources defeats the purpose. On the other hand, my sense is that because much of the core structure of Unicode was in place in 2006, many of the basic ways of working with Unicode are the same. Though I’m no expert, my sense is that working with Unicode in HTML is unchanged, even for complicated stuff (bidi), while working with Unicode in MS Word can still be a pain.

But the real reason to read this book isn’t so much the practical advice– much of which you’d be better off looking up on StackExchange anyway– but the lucid explication of the structure and design of the Unicode framework. Not all of the explanations are equally clear– I found the first chapter a bit muddled, oddly– but Korpela remains a useful guide to the Unicode terrain.