mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Promote ::class documentation to its own subsection for direct linking.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@330569 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
bc3ff3cf1b
commit
c2f8c648c8
1 changed files with 34 additions and 31 deletions
|
@ -102,37 +102,6 @@ $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>
|
||||
|
@ -309,6 +278,40 @@ a default value
|
|||
</example>
|
||||
</sect2>
|
||||
|
||||
<sect2 xml:id="language.oop5.basic.class.class">
|
||||
<title>::class</title>
|
||||
|
||||
<para>
|
||||
Since PHP 5.5, the <literal>class</literal> keyword is also used for class
|
||||
name resolution. You can get a string containing the fully qualified name
|
||||
of the <literal>ClassName</literal> class by using
|
||||
<literal>ClassName::class</literal>. This is particularly useful with
|
||||
<link linkend="language.namespaces">namespaced</link> classes.
|
||||
</para>
|
||||
<para>
|
||||
<example xml:id="language.oop5.basic.class.class.name">
|
||||
<title>Class name resolution</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
namespace NS {
|
||||
class ClassName {
|
||||
}
|
||||
|
||||
echo ClassName::class;
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
NS\ClassName
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
</sect2>
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
Loading…
Reference in a new issue