Difference between :: and -> in PHP
Posted
by vrode
on Stack Overflow
See other posts from Stack Overflow
or by vrode
Published on 2010-05-10T17:13:53Z
Indexed on
2010/05/10
17:24 UTC
Read the original article
Hit count: 140
I always see people in serious projects use :: everywhere, and -> only occasionally in local environment.
I only use -> myself and never end up in situations when I need a static value outside of a class. Am I a bad person?
As I understand, the only situation when ->
won't work is when I try following:
class StaticDemo {
private static $static
}
$staticDemo = new StaticDemo( );
$staticDemo->static; // wrong
$staticDemo::static; // right
But am I missing out on some programming correctness when I don't call simple public methods by ::
?
Or is it just so that I can call a method without creating an instance?
© Stack Overflow or respective owner