Hudzilla.org - the homepage of Paul Hudson
Contents > Preface Wish List | Report Bug | About Me ]

1.5     A note for programmers coming from Perl

This 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!





<< 1.4 How to use this book   1.6 A note for programmers coming from C, C++, or Java >>
Table of Contents
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!



Top-right shadow
 
Bottom-left shadow Bottom shadow

Comments from other readers
A PHP User - 13 Oct 2008

You should make this URL an actual link.

http://www.php.net/manual

Pedro - 13 Oct 2008

I'll try to remember that functions don't mean the same in other languages.

Ssan Diego CA US 26 Jan 2006



Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.

If you are reporting an error in the content, please tell me directly.

Your name/email address:
Your comment:
 
Now, in order to verify that you're a real person, please answer this simple question: what is one plus two?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow