Cover image for post studlyCaps or under_scores in PHP5's OO interface?

studlyCaps or under_scores in PHP5's OO interface?

The big question for PHP5 currently is the discussion around the new dual-syntax system, which allows extensions to be used with a procedural and an object oriented interface. The problem is, that PHP usually uses "_" to devide parts of a function name, where most OO languages (e.g. Java, C#,...) use studlyCaps to divide method name parts. And this is the common way in OO programming with PHP, too (as we from PEAR defined once upon a time...).

There was (and I guess already is) a big discussion on the PHP internals mailinglist about that issue and PHP internal developers ran into a heavy guerilla war about that issue. John Coggeshall recently called for comments from the PHP userland on his blog, what I guess is a pretty good idea, since PHP users will have to live for a long time.

In my personal opinion, PHP's OO interface should stick to the standards which were defined by PEAR. Usually PEAR follows inventions of PHP, the PHP guys now should one time follow PEAR. In general the "foo_bar against fooBar" discussions seems to result in a matter of personal favor. There are many arguments for and against each style, but I guess the most effective argument is what users want. IMHO, most OO PHP users should be used to the studlyCaps way and for that PHP itself should use it. No matter if methods then do not look like functions, but indeed, they aren't the same.

But take your own picture on John's Weblog, the PHP internals thread and your personal experiences and leave a comment here or on John's blog.


I agree with you that fooBar should be used, but only for the sake of consistency. I don't agree with the argument that PHP should follow PEAR conventions as a way to repay some past favor (PEAR using PHP conventions).

Chris Shiflett at 2004-03-23

Just to clearify: I did not mean that PHP should follow PEAR because of some historical reasons. Just because of the fact that a standard has been implemented for OO style PHP programming.

Toby at 2004-03-23

But php is not object oriented at the basement it is like c++ you can program with the case that you want, and it is the drawback of php. And the fact OO orienting it is full of nonsense to my advice.

galactica at 2004-03-26


But what has this to do with the studlyCaps discussion?

Toby at 2004-03-26