October 29th, 2008
Posted by scotti3g
Federico makes an interesting point about the PHP Namespaces Controversy on his PHP::Impact blog. I never thought about the mess that is PHP until I saw his comparison table:
Java: Attribute/Method access: foo.bar Static method access: Foo.bar Package access: foo.bar.baz C#: Attribute/Method access: foo.bar Static method access: Foo.bar Namespace access: foo.bar.baz Python: Attribute/Method access: foo.bar Static method access: Foo.bar Module access: foo.bar.baz PHP: Attribute/Method access: $foo->bar Static method access: Foo::bar Namespace access: C:\foo\bar\baz
I guess I can’t complain though as the syntax of PHP is still a lot closer to more “traditional” languages than something like Ruby (not talking about the namespace, just the language in general)… :)
PHP’s access things are taken from C/C++.
C/C++ have . -> and :: for different things.
Having the :: makes it easier to see static methods, as you and stick a non-initialiuzed class into a variable if you want (although usually that would be silly)