Laravel中的双冒号是什么意思 [英] What does double colon in laravel means

查看:497
本文介绍了Laravel中的双冒号是什么意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例:

Auth::guard($guard)->guest()

我不明白在laravel框架中双冒号(::)表示什么.来自 http://php.net/manual/en/language.oop5. paamayim-nekudotayim.php 我了解到,它代表范围解析运算符,用于访问类的静态,常量和重写属性或方法.但是从laravel中,我了解到Auth表示类Facade的别名,因此我需要对上面的示例进行解释,尤其是guard(parameter)->guest()的意思.
我对php还是很陌生,现在为我的后端学习laravel框架.

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.

推荐答案

::范围解析运算符

这称为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.

参考

Auth::guard($guard)->guest():在这一行中,您使用静态类Auth guard()方法.要使用静态类的功能,请使用::范围解析运算符.

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.

这篇关于Laravel中的双冒号是什么意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆