2

I am currently learning laravel framework and most of the time it's using namespace, and to further my understanding about namespace I read articles and php documentation about it but none of those discuss or maybe I'm missing the concept as shown below.

Illuminate\Contracts\Http\Kernel::class

I don't understand much about ::class

What is it for?

Can anyone explain it to me?

Fil
  • 8,225
  • 14
  • 59
  • 85

1 Answers1

2

The special ::class constant are available as of PHP 5.5.0, and allows for fully qualified class name resolution at compile, this is useful for namespaced classes:

namespace foo {
    class bar {
    }

    echo bar::class; // foo\bar
}

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

Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279