1

I noticed in Laravel this syntax:

Illuminate\Foundation\Providers\ArtisanServiceProvider::class

What does the ::class operator do?

Ben Dauphinee
  • 4,061
  • 8
  • 40
  • 59

2 Answers2

2

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.

Charlie Schliesser
  • 7,851
  • 4
  • 46
  • 76
2

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;
   }
?>

http://php.net/manual/en/language.oop5.basic.php