What does double colon in laravel means

杀马特。学长 韩版系。学妹 提交于 2019-12-04 11:14:11

:: 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.

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.
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!