A note for programmers coming from Perl
Before using PHP, Perl was my language of choice for web applications, so I am not short of experience in the language.
The common denominator between PHP and Perl is that they both have roughly the same roots: they are both Unix-like languages, loosely based on C. As such, one of the biggest advantages and the biggest disadvantages in having already learnt Perl is look-alikes. That is, functions or constants that look almost the same, but are different. Or, worse yet, functions that are called the same name but function differently.
For example, the PHP function substr() looks just like the Perl functions substr(). Happily enough, it works in precisely the same manner in both languages. On the other hand, a function like rtrim() looks to many like the Perl function chomp() because it trims whitespace from the right-hand side of a string. However, it's actually quite different in that the Perl version only trims new-line characters and returns the number of characters that have been trimmed, whereas the PHP version trims all whitespace by default, and returns the trimmed string.
I strongly recommend that you consult a reference (either this book or the PHP manual at http://www.php.net/manual) if you ever have any doubts as to how a function works. Don't just assume that because a function has the same name that it works in the same way!
Next chapter: A note for programmers coming from C, C++, or Java >>
Previous chapter: How to use this book
Home: Table of Contents