I need a quick bitch.
I love PHP. It’s everywhere. All my sites are written in it. My CMS is written in it. My blog engines, WordPress and b2evolution, are written in it. It’s free. It runs on any platform. Hosts all support it. With PHP 5 they’ve even done a lot of work on PHP4’s main downfall – lack of OOP support.
One thing really pisses me off though – it’s totally inconsistent. Consider these two functions:
Take a close look. See the signatures?
string strstr ( string $haystack , mixed $needle [, bool $before_needle ] )
bool in_array ( mixed $needle , array $haystack [, bool $strict ] )
In in_array the first parameter is what you’re looking for and the second is what you’re looking in (more or less consistent with preg_match). In strstr (and its derivatives) this order is reversed. Who on Earth let that slip through? I’m yet to find a free text editor that will tell you which parameters a given function expects (Dreamweaver does a decent job but it’s bloody expensive for a text editor!) the way Visual Studio does for C#, which I use a lot in work. Given that situation, you’d expect consistency in this sort of thing. Apparently not so. Instead, every time I want to use one of these functions I have to do a quick Google to bring me to the PHP manual page to tell me which order the parameters come in.
Of course they can’t even fix that without breaking backwards compatibility either, so we’re probably stuck with it. Bloody marvellous!