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

WBOY
Release: 2016-06-23 13:20:31
Original
2051 people have browsed it

::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;  
Copy after login


为了解决这个问题采用新的FooBar::class语法,它返回类的完整类别名称  
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template