PHP’s object syntax

PHP 5 is out, and with it comes better support for objects.

Having been smitten with another P language, I haven’t played with PHP much recently, but one thing struck me as odd.

What’s up with the object references in that language?

PHP uses -> as a seperator, instead of a period — does that strike anyone as odd?

Other languages use dot-notation — which is a fancy term for a period.

So while some of us would do this: foo.bar()

PHP users have to do this: foo->bar()

While the arrow is nice, a good visual way to indicate that you’re accessing an object’s method or properties, is it really worth two keystrokes (three if you count the shift to get the >)?

It may seem minor to some, but it feels fairly disruptive to me.

My hands are used to belting out a period, and often — us journalists like short sentences, and we like our periods (semicolons need not apply).

P.S. Apologizes for not mention our new Adsense ads — its a trial at the moment. If you find them too much, do drop a comment… we’re about as attached to them as we are to -> notation.

This entry was posted in Technology. Bookmark the permalink.