PHP vs Perl part II
Perl has these tiny little functions that make me use it more for small, personal one-time use things. PHP has support for some of them but often it feels just wrong and not supposed to be there. My favourite example is unless() (should I even add those ()?). Perl has the most awesome function ever:
print 'Hello world.' unless $world eq 'Destroyed';
That all, in one line. PHP has (together with Javascript) a good but too long and confusing option for, the shorter version of if(), I use it all the time. It would look like this in PHP:
print ($world == 'Destroyed') ? '' : 'Hello world';
Ok, that's a pretty sweet function but it requires me to type too much special characters.
The second function I would like to talk about is ... well it has no name, it's just something you can do. In short, it is this:
($arrayOptionOne,$arrayOptionTwo) = @array;
That is the Perl version, PHP has this one too but they really had to add a specific named function for it:
list($arrayOptionOne,$arrayOptionTwo) = $array;
And then one of the functions I use all the time for things that involve editing files:
open(FileHandle,"<fileName");
print join("",<FileHandle>");
That's it! That's just it, we have read a complete file in two lines of code. The PHP version is horrifying here:
$fileHandle = fopen('fileName', 'r');
$data = fread($fileHandle, filesize('fileName'));
fclose($fileHandle);
print $data;
Now I hear some people say: what's wrong with file_get_contents() then? Nothing, except it doesn't allow you to change the mode parameters (you know: read, write, append, ..) which is quite useful.
After all, anything that I need to write quickly for a task is written in Perl, but in the end PHP is the most powerful language for websites so don't get all mad on me for not mentioning that before.

Okay. You said it. PHP is the most powerful language for websites, but how would I know, I don’t write code. Like html, I’d learn it as I go along.
I want to switch to an PHP website with logins, cart, and stuff, stuff, stuff. So I’m asking - and people are telling me - to us osCommerce.
Tell me what to use.
I have almost zero experience using shopping carts, but I’ve seen a lot of websites using osCommerce, but also Squirrelcart. I think you won’t be needing any PHP knowledge for using them.
[...] post I discussed the sick amount of functions in PHP compared to Perl, in the second one the reason why writing Perl applications goes faster and now in this third and final post, I’ll discuss external [...]