Why we don’t like PHP

I’ve started using PHP lately, and I find that I quite like it, as a language. However, there’s a lot of anti-PHP sentiment on #apache (on freenode.net), and folks often wonder what the source of that is. Well, there’s several main reasons, some of which are:

  1. The anti-Apache2 FUD spread by the PHP folks
  2. The #php redirect effect
  3. The “scripture with commentary” nature of the documentation
  4. The misuse of AddType vs AddHandler

The first one of these, the anti-Apache2 FUD issue, is one that’s important enough that I’ll probably write as a seperate article.

The next one, the “#php redirect effect,” is pretty irritating. On #apache, we attempt to be very helpful, and so we end up answering questions on a variety of topics which are, strictly speaking, off-topic. Invariably, however, when we refer someone to #php for questions which seem to be likely to be more in the experience of folks familiar with PHP, they say, that’s an Apache problem, and send them back to #apache. This is very irritating behavior, and results in a lot of frustrated people with unanswered questions. There are indeed questions which are, strictly speaking, Apache questions. However, when they are configuration issues which would necessarily be more familiar to frequent users of PHP, it would be courteous if they were to be willing to handle those questions.

The third issue is one on which, obviously, a lot of people disagree with me. I find the PHP documentation deeply irritating. The model that they have chosen, which I call the “Scripture with commentary” approach, works kinda like this. Someone – the authority, one presumes, writes a brief piece of official documentation. Then dozens of the masses write additional commentary as addenda to that official documentation. These comments might be correct, or they might not. Who’s to know? There doesn’t seem to be any official method for resolving those comments back into the official documents. So you can’t actually know which bits are true, and which bits are uninformed ignoramuses. Then, too, there are a lot of heretical remarks, which simply criticize or complain. These are not only unhelpful, but they distract from the main flow of the truth, and so further serve to confuse the issue.

However, I should say that the PHP docs get a lot of acclaim for being wonderful, so there are obviously a lot of people that disagree with me.

Finally, there’s something that amounts to not much more than a pet peeve. The PHP docs recommend the use of AddType to enable php parsing:

AddType application/x-httpd-php .php

That’s just *wrong.* The correct way to do this would be to use AddHandler. Using AddType confuses people about what AddType means. So you should instead use:

AddHandler application/x-httpd-php .php

What’s especially irritating is that both work. But it’s still wrong.

AddType associates a Content-Type with a file extension, and that tells the browser how to deal with a particular data stream. AddHandler, on the other hand, maps a handler to a file extension.

Stated more simply, AddType tells the browser what to do with a file, and AddHandler tells the server what to do with a file. PHP is handled by the *server*, not by the browser, and so AddHandler is more appropriate.

So, you see, none of these are technical objections with PHP itself, but more deal with the community. It’s a shame when technical communities are divided by community issues, rather than technology issues. But it seems that that’s almost always the way of it.

So, once again, for the record, I’m becoming quite fond of PHP, almost in spite of myself. It makes development quick and easy. If one can get past other objections.