Difference between double colon and arrow operators in PHP? [duplicate]

:: is for static elements while -> is for instance elements.

For example:

class Example {
  public static function hello(){
    echo 'hello';
  }
  public function world(){
    echo 'world';
  }
}

// Static method, can be called from the class name
Example::hello();

// Instance method, can only be called from an instance of the class
$obj = new Example();
$obj->world();

More about the static concept

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)