1.5 A note for programmers coming from PerlThis is NOT the latest copy of this book; click here for the latest version.
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 is 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!
|
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.
My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!
|