According to the documentation, http://php.net/manual/en/migration55.new-features.php#migration55.new-features.class-name, you can use it to get the fully qualified name of a class.
In your case, let's assume the Locale
class is defined like this:
file1.php
<?php
namespace App\Core;
class Locale {}
echo Locale::class; // output - App\Core\Locale
In a separate file, you could require
/autoload
the file,
file2.php
<?php
require_once #pathToFile1/file1.php;
use App\Core\Locale;
echo Locale::class; // output - App\Core\Locale
We can also see from this that we no longer have to save our class name in a variable as we can always call Locale::class
and get going.
To address one of the comments on the question, yes, class
is a keyword and using it for function name usually result in a parse error
.. That changed in PHP 7 though...thus you can define a function and name it class
, function
etc. It's best not to do this though unless you think it's absolutely necessary.