2008-05-05

The pros from Dover

Is this sounding like one long rant about php?

I wonder why...

Today's rant is about the quality of PHP documentation. I've taken to using the official PHP documentation on the official website. Fairly often I am disappointed because there are missing parts: the developers wrote some code quickly and didn't bother to document. Odd for an official site, but okay.

So right now I am looking for info on doing HTTP digest authentication in php. There is a page about it that provides some examples that simply don't work. The regex for parsing Authorization headers is defective and none of the solutions people have offered up in the comments have helped me at all...

Fine.

The funny thing is that everyone insists on using regexes. I like regexes just fine, and with Perl I used to consider myself reasonably good with them. Anyhow, the consensus seemed to be that you needed a good regex. After screwing around for awhile, I was about to write my own solution using explode and substr and a lot of strpos(). But it was getting late...

So, after wasting an evening thinking that there was something I wasn't getting, I decide to look around for a library. There isn't much that jumps out at me right away, but I end up finding Auth HTTP which extends the Auth class.

I don't want to install Auth (trying to go light) but I download Auth HTTP to look at how they parse the Authorization header. First of all, I am impressed by how clean the code is. Then I find my function, and guess what: explode, substr, strpos.

No comments: