What does "::" mean in PHP? [duplicate]

3

In PHP, what do these four dots mean? ::?

I see a lot on things like: stackOverflow :: class

    
asked by anonymous 23.08.2017 / 21:32

1 answer

7

These four dots mean that you are calling a static method of a class. A static method can be called without the need to instantiate an object of the class. Ex:

Class teste() {
  public function metodoTradicional() {
    echo 'Tradicional';
  }
  public static function metodoEstatico() {
    echo 'Estático';
  }
}

teste::metodoTradicional(); // vai dar erro
teste::metodoEstatico(); // vai imprimir 'Estático'

More on static methods you can read in the official documentation: link

    
23.08.2017 / 21:37