MyClass :: class - get a string representation of MyClass

The double colon (: :) is the scope resolution operator .

Used to access protected methods and properties (and constants).

However, I have seen using :: class to return a string representation of a class. For instance:

namespace App;
class MyClass
{

}

var_dump(MyClass::class); # string(11) "App\MyClass"

I have searched all over the world for documentation of this behavior.

Is the above code also using a scope resolution operator, or is it something completely different? If so, what is his name?

If it uses SRO, does this mean that PHP is putting the static “class” property behind the scenes? (I could not override this static property though)

+4
source share
2 answers

PHP5.5, . http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.class.class

. (. $), , class. php.net:

:: class - . , , , . , , . .

+3

operator:: PHP 5.5 .

0

Source: https://habr.com/ru/post/1628622/


All Articles