I love PHP because it comes with a santa’s bag size feature set, and I am charmed by PHP because these features often make no sense and are wildly inconsistent across the language. My friend says he won’t do web development because it requires ‘tribal knowledge’ and I think this is what he’s talking about. Let’s talk about string functions.
The function to search for a string in a string is strstr. The function to perform that search case insensitively is stristr. This is a little weird but it makes sense. From these two functions you might assume that the naming convention in PHP for built in functions is all lower case, one word. Wrong.
The function to replace a string in a string is str_replace. To PHP’s credit, the function to do a case insensitive replacement is str_ireplace. Substring? substr. Substring count? substr_count.
What makes me love PHP to death though, is all of the weird built in features it has. Just go to the language reference and poke around. You’ll find things like, hebrev which does Hebrew text conversions. Why? Why not. I can’t count the number of times I’ve found a function built into PHP that solves whatever problem I’m currently up against.
There are more issues than just naming conventions. When you can/should use objects, change in-place (though JS is a great offender here too), return values, endless falsies. I get the feeling that there wasn’t much vision behind PHP. Incremental changes added cool new features and ideas, but added them with tape and rubber bands. In fact, this is exactly what happened. Said the co-author of PHP:
I don’t know how to stop it, there was never any intent to write a programming language… I have absolutely no idea how to write a programming language, I just kept adding the next logical step on the way.
PHP is case insensitive. array_merge_recursive is the same as aRrAy_MeRgE_rEcUrSiVe. Magnificent.
PHP is Ded
I’ve heard a lot of people say that PHP is dying, and that does seem to be the case, or at least the trend. Python and Node are great backend languages which I’ve greatly enjoyed using in the past—but something always brings me back to PHP. It’s like going to your home town and eating in the local diner you’ve been to a thousand times. Late at night. And you see the ghosts of all the good times you’ve had there in the reflection of your coffee, steaming before you as you contemplate the long road ahead.