mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
Fixed whitespace.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@321337 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
cddc79d233
commit
871545d23e
1 changed files with 58 additions and 59 deletions
|
@ -1,37 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 xml:id="language.oop5.paamayim-nekudotayim" xmlns="http://docbook.org/ns/docbook">
|
||||
<title>Scope Resolution Operator (::)</title>
|
||||
<sect1 xml:id="language.oop5.paamayim-nekudotayim" xmlns="http://docbook.org/ns/docbook">
|
||||
<title>Scope Resolution Operator (::)</title>
|
||||
|
||||
<para>
|
||||
The Scope Resolution Operator (also called Paamayim Nekudotayim) or in
|
||||
simpler terms, the double colon, is a token that allows access to
|
||||
<link linkend="language.oop5.static">static</link>,
|
||||
<link linkend="language.oop5.constants">constant</link>, and overridden
|
||||
properties or methods of a class.
|
||||
</para>
|
||||
<para>
|
||||
The Scope Resolution Operator (also called Paamayim Nekudotayim) or in
|
||||
simpler terms, the double colon, is a token that allows access to
|
||||
<link linkend="language.oop5.static">static</link>,
|
||||
<link linkend="language.oop5.constants">constant</link>, and overridden
|
||||
properties or methods of a class.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
When referencing these items from outside the class definition, use
|
||||
the name of the class.
|
||||
</para>
|
||||
<para>
|
||||
When referencing these items from outside the class definition, use
|
||||
the name of the class.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
As of PHP 5.3.0, it's possible to reference the class using a variable.
|
||||
The variable's value can not be a keyword (e.g. <literal>self</literal>,
|
||||
<literal>parent</literal> and <literal>static</literal>).
|
||||
</para>
|
||||
<para>
|
||||
As of PHP 5.3.0, it's possible to reference the class using a variable.
|
||||
The variable's value can not be a keyword (e.g. <literal>self</literal>,
|
||||
<literal>parent</literal> and <literal>static</literal>).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Paamayim Nekudotayim would, at first, seem like a strange choice for
|
||||
naming a double-colon. However, while writing the Zend Engine 0.5
|
||||
(which powers PHP 3), that's what the Zend team decided to call it.
|
||||
It actually does mean double-colon - in Hebrew!
|
||||
</para>
|
||||
<para>
|
||||
Paamayim Nekudotayim would, at first, seem like a strange choice for
|
||||
naming a double-colon. However, while writing the Zend Engine 0.5
|
||||
(which powers PHP 3), that's what the Zend team decided to call it.
|
||||
It actually does mean double-colon - in Hebrew!
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>:: from outside the class definition</title>
|
||||
<programlisting role="php">
|
||||
<example>
|
||||
<title>:: from outside the class definition</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class MyClass {
|
||||
|
@ -44,18 +44,18 @@ echo $classname::CONST_VALUE; // As of PHP 5.3.0
|
|||
echo MyClass::CONST_VALUE;
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
Three special keywords <varname>self</varname>, <varname>parent</varname> and
|
||||
<varname>static</varname> are used to access properties or methods from inside
|
||||
the class definition.
|
||||
</para>
|
||||
<para>
|
||||
Three special keywords <varname>self</varname>, <varname>parent</varname> and
|
||||
<varname>static</varname> are used to access properties or methods from inside
|
||||
the class definition.
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>:: from inside the class definition</title>
|
||||
<programlisting role="php">
|
||||
<example>
|
||||
<title>:: from inside the class definition</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class OtherClass extends MyClass
|
||||
|
@ -74,21 +74,21 @@ echo $classname::doubleColon(); // As of PHP 5.3.0
|
|||
OtherClass::doubleColon();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
When an extending class overrides the parents definition of a method,
|
||||
PHP will not call the parent's method. It's up to the extended class
|
||||
on whether or not the parent's method is called. This also applies to <link
|
||||
linkend="language.oop5.decon">Constructors and Destructors</link>, <link
|
||||
linkend="language.oop5.overloading">Overloading</link>, and <link
|
||||
linkend="language.oop5.magic">Magic</link> method definitions.
|
||||
</para>
|
||||
<para>
|
||||
When an extending class overrides the parents definition of a method,
|
||||
PHP will not call the parent's method. It's up to the extended class
|
||||
on whether or not the parent's method is called. This also applies to <link
|
||||
linkend="language.oop5.decon">Constructors and Destructors</link>, <link
|
||||
linkend="language.oop5.overloading">Overloading</link>, and <link
|
||||
linkend="language.oop5.magic">Magic</link> method definitions.
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>Calling a parent's method</title>
|
||||
<programlisting role="php">
|
||||
<example>
|
||||
<title>Calling a parent's method</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class MyClass
|
||||
|
@ -113,15 +113,15 @@ $class = new OtherClass();
|
|||
$class->myFunc();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
See also <link linkend="language.oop5.basic.class.this">some examples of
|
||||
static call trickery</link>.
|
||||
</para>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
See also <link linkend="language.oop5.basic.class.this">some examples of
|
||||
static call trickery</link>.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
|
@ -142,4 +142,3 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
|
|||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
|
||||
|
|
Loading…
Reference in a new issue