Skip this bit if you don't know Perl.
The major changes that most Perl coders find (in my experience at least) when using PHP are:
*
In PHP there is only one kind of array, and it's the hash (or named array), and you should treat every array like it's a hash (i.e., in a loop over an array, step through each key rather than going through the numbers on a list)
*
In PHP, variables, lists, and hashes are ALL signified by a $ at the front of the name. In Perl, depending on the context, either $, @, or % is required.
*
Filehandles are replaced by file pointers, and the file pointers are stored in a variable. This is different from Perl because in Perl, filehandles have their own namespace. So where in Perl one would do
open(MYFILE, ">newfile.txt") or die("Couldn't open file to write");
in PHP, this is
if (! $myfile = fopen("newfile.txt", "w")) die("Couldn't open file to write");
*
There is no regular expression operator in PHP - regular expression matching, substitution, etc. are all standard functions. This tidies up the syntax no end, in the author's opinion. However, on most PHP builds, PCRE is built in which supplies Perl-compatible regular expression functions for some seriously funky wizardry if you're that perverted a programmer that you feel you need to make your code illegible ;-)
*
In Perl, the default return value of a function (if one is not specifically given) is the result of the last statement in the function. In PHP, there is no default return value; this isn't in the PHP manual, however, so it may change in future. In all cases, it's wise to use a return value in a function.
*
Only one item can be returned from a function, though that one item can be a list. This is discussed later on.