I don't know what it's doing when we have this situation:
Foo::Bar
It looks like a path.
The double colon ( :: ) may refer to: an analogy symbolism operator, in logic and mathematics. a notation for equality of ratios. a scope resolution operator, in computer programming languages.
Since PHP 5.5, the class keyword is also used for class name resolution. You can get a string containing the fully qualified name of the ClassName class by using ClassName::class. This is particularly useful with namespaced classes.
self operator: self operator represents the current class and thus is used to access class variables or static variables because these members belongs to a class rather than the object of that class.
Basically its know as Scope resolution operator (::) Simply it is token which allow access to static, constant and overridden properties of method of a class. Example- in laravel we call model like this.
The ::
operator is the scope resolution operator. It is used to access class constants or static properties and methods, either from outside the class:
ClassName::CONSTANT_VALUE ClassName::staticMethod()
Or within a class method to reference the same or a parent class using self
and parent
:
self::CONSTANT_VALUE self::staticMethod() parent::CONSTANT_VALUE parent::staticMethod()
That's (generally) for accessing a static method or property in a class. It's called the scope resolution operator, or Paamayim Nekudotayim (which leads to some amazingly confusing error messages!). See http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With