I noticed in Laravel this syntax:
Illuminate\Foundation\Providers\ArtisanServiceProvider::class
What does the ::class operator do?
I noticed in Laravel this syntax:
Illuminate\Foundation\Providers\ArtisanServiceProvider::class
What does the ::class operator do?
From the docs:
Since PHP 5.5, the class keyword is also used for class name resolution. You can get a string containing the fully qualified name of the ClassName class by using ClassName::class. This is particularly useful with namespaced classes.
from PHP doc "Since PHP 5.5, the class keyword is also used for class name resolution. You can get a string containing the fully qualified name of the ClassName class by using ClassName::class. This is particularly useful with namespaced classes."
<?php
namespace NS {
class ClassName {
}
echo ClassName::class;
}
?>