mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
ClassName::class
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@330216 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
beb09db76b
commit
0bae036804
1 changed files with 31 additions and 0 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue