ClassName::class

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@330216 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Jakub Vrana 2013-05-14 20:44:08 +00:00
parent beb09db76b
commit 0bae036804

View file

@ -102,6 +102,37 @@ $this is defined (A)
$this is not defined.
$this is defined (B)
$this is not defined.
]]>
</screen>
</example>
</para>
<para>
Since PHP 5.5, the <literal>class</literal> keyword is also used for class
name resolution. You can get a string with fully qualified name of the
<literal>ClassName</literal> class with <literal>ClassName::class</literal>.
This is particularly useful with <link linkend="language.namespaces">
namespaces</link>.
</para>
<para>
<example xml:id="language.oop5.basic.class.name">
<title>Class name resolution</title>
<programlisting role="php">
<![CDATA[
<?php
namespace N {
class C {
}
echo C::class;
}
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
N\C
]]>
</screen>
</example>