What is the difference between accessing a property from the class through $this or through new operator or through scope resolution operator in PHP?
$this-> vs ->开发者_运维技巧 vs :: in PHP
$this-> can be used from inside a class when referencing itself.
$object-> is used from outside the class when referencing a specific object.
$class_name:: is used when referencing a static property or method of a specific class.
The differen between
$object->property;
Class::property;
is, that the first one access a object property, whereas the second one access a (static) class property. I really dont know, what you mean by "through new operator", because via new no property is accessable in any way, because new just creates a new object instance of a class. However, $this->property is exactly the same, as the first example above, but $this is only valid inside an object method and always references the object itself.
加载中,请稍侯......
精彩评论