-2

what is the difference between $object::$variable and $object->variable

both of them can be used to achieve the same but creates difference when the class member-variable is static as follows-

$object::$variable :- This syntax allows the static variable to be achieved through the object

But

$object->variable :- This syntax does not allow the static variable to be achieved through the object.

What is the semantic difference between the two?

4

2 回答 2

2

$object::$variable and $object->variable

以上两者对于访问类属性都是有效的。

唯一的区别是$object::$variable用于访问静态属性,而 as$object->variable用于从实例访问类的属性。

有关更多单词,请参阅Amal Murali评论问题链接。

于 2013-09-10T08:55:04.420 回答
0

$object::$variable 指的是类的 $variable,$object->variable 指的是这个类的实例的 $variable。

于 2013-09-10T08:54:11.053 回答