The second example doesn't automatically instantiate the object. So in the second way of calling, if you had used $this in the function, you will get a error like :
PHP Fatal error: Using $this when not in object context.
In general, -> is used to call a non-static method, :: is used to call a static method.
But it's not so strict in php.
For example:
error_reporting(E_ALL);
class A {
public static function staticFunc() {
echo "static";
}
public function instanceFunc() {
echo "instance";
}
}
A::instanceFunc(); // echo "instance"
$a = new A();
$a->staticFunc(); // echo "static"
The two method called above run successfully.
Because php always implementing new features in a progressive way, to ensure compatibility, which may resulted in some detail doesn't cared much about.
But if you set the error_reporting level to E_STRICT , you will find a E_STRICT error like this:
Strict Standards: Non-static method A::instanceFunc() should not be called statically
The only difference in these two ways is that: when you calling a method with :: , you can't use variable $this .
But it's still recommended you to use these two ways strict as in other Object Oriented language.
You can get more information in http://www.php-internal.com/book/?p=chapt05/05-02-class-member-variables-and-methods