问题
Example :
Auth::guard($guard)->guest()
I dont get what double colon (::) notation means in laravel framework. from http://php.net/manual/en/language.oop5.paamayim-nekudotayim.php I learn that it stand for scope resolution operator to access static, constant and overridden properties or methods of a class. but from laravel I learn that Auth means the alias for class facade so I need an explanation of the example above especially guard(parameter)->guest() means.
I'm still new to php and now learning laravel framework for my back-end.
回答1:
:: Scope Resolution Operator
This is called as scope resolution operator. This operator is used to refer the scope of some block or program context like classes, objects, namespace and etc. For this reference an identifier is used with this operator to access or reproduce the code inside that scope.
Reference
Auth::guard($guard)->guest() : In this line you are using the guard() method of static class Auth. To use the function of a static class we use :: Scope Resolution Operator.
回答2:
You are likely encountering this as a way of accessing a static method or property of a class.
For example:
class Foo
{
public static function bar()
{
return "bar";
}
}
Foo::bar // access the bar method without instantiating the Foo class.
来源:https://stackoverflow.com/questions/39198357/what-does-double-colon-in-laravel-means