views:

41

answers:

2

Possible Duplicate:
In PHP, whats the difference between :: and -> ?

I've been seeing this class::function more in some code examples and thought it was the same as this class->function, but I wanted to know if there is a use case as to when I would use one over the other?

+1  A: 

class::function() is a call to a static method defined in a class, $x->function() is a call to the function() method in a class instance ($x)

The appropriate page of the PHP manual advises you of when a method or property should be defined as static or not

Mark Baker
+2  A: 

class::function is used for static function, its been used for a quick access of a function ,as you dont have to create any object to access the function.

class->function , is used when you want to class property and features as object.

best would be if you can google , encapsulation and polymorphism in php5

Both are useful and important part of OOPS, it depend on your project need.

check this link below

http://stackoverflow.com/questions/3173501/in-php-whats-the-difference-between-and

JapanPro