In Object oriented PHP we use ::
operator and ->
operator to access object in a class. What are the differeces between those two operator beside ::
operator for static and ->
operator for non static. And why there is distinction between those two operator, unlike another programming language which use just .
(dot) operator for accessing class object?
Asked
Active
Viewed 584 times
2
-
1because it's different language? – Your Common Sense Apr 13 '11 at 15:07
-
2Because in PHP classes are not objects unlike the other languages you refer to. Other languages use meta-objects to describe the class, which is how you implement the static operator as you describe. But in PHP it's a static structure so it's nothing more than an identifier. And since it's nothing more than an identifier, using an instance operator on an identifier wouldn't make sense. – ircmaxell Apr 13 '11 at 15:09
-
1*(related)* [What does that symbol mean in PHP](http://stackoverflow.com/questions/3737139/reference-what-does-this-symbol-mean-in-php) – Gordon Apr 13 '11 at 15:14