Home  >  Article  >  Backend Development  >  'model' => AppUser::class,最后这class是啥意思?

'model' => AppUser::class,最后这class是啥意思?

WBOY
WBOYOriginal
2016-06-23 13:20:312054browse

::class是啥意思?


'users' => [
            'driver' => 'eloquent',
            'model' => App\User::class,
        ],


搜半天不知道搜啥关键词。。


回复讨论(解决方案)

应该是user这个类下面的一个静态属性

App\User::class 返回类名 “App\User”

App\User::class 返回类名 “App\User”



感谢!根据您的返回类名4个字搜索了下。
PHP5.5t特性,获取完整类名称  

PHP5.3 中引入命名空间的别名类和命名空间短版本的功能。虽然这并不适用于字符串类名称  

use Some\Deeply\Nested\Namespace\FooBar;    // does not work, because this will try to use the global `FooBar` class    $reflection = new ReflectionClass('FooBar');   echo FooBar::class;  


为了解决这个问题采用新的FooBar::class语法,它返回类的完整类别名称  
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn