July 16, 2004

PHP’s object syntax

PHP 5 is out, and with it comes better sup­port for objects.

Having been smit­ten with another P lan­guage, I haven’t played with PHP much recently, but one thing struck me as odd.

What’s up with the object ref­er­ences in that language?

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

Other lan­guages 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 indi­cate that you’re access­ing an object’s method or prop­er­ties, is it really worth two key­strokes (three if you count the shift to get the >)?

It may seem minor to some, but it feels fairly dis­rup­tive to me.

My hands are used to belt­ing out a period, and often — us jour­nal­ists like short sen­tences, and we like our peri­ods (semi­colons need not apply).

P.S. Apol­o­gizes for not men­tion 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.

Filed under: Technology

Next:
Previous:

Related

Comments