Home  |  Linux  | Mysql  | PHP  | XML
From:Kalle Sommer Nielsen Date:Tue Aug 12 15:26:22 2008
Subject:cvs: phpdoc /en/language/oop5 constants.xml interfaces.xml
kalle		Tue Aug 12 21:26:22 2008 UTC

  Modified files:              
    /phpdoc/en/language/oop5	constants.xml interfaces.xml 
  Log:
  Document that interfaces can have constants
  
http://cvs.php.net/viewvc.cgi/phpdoc/en/language/oop5/constants.xml?r1=1.16&r2=1.17&diff_format=u
Index: phpdoc/en/language/oop5/constants.xml
diff -u phpdoc/en/language/oop5/constants.xml:1.16 phpdoc/en/language/oop5/constants.xml:1.17
--- phpdoc/en/language/oop5/constants.xml:1.16	Fri Apr 18 19:22:12 2008
+++ phpdoc/en/language/oop5/constants.xml	Tue Aug 12 21:26:21 2008
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.16 $ -->
+<!-- $Revision: 1.17 $ -->
  <sect1 xml:id="language.oop5.constants" xmlns="http://docbook.org/ns/docbook">
   <title>Class Constants</title>
   <para>
@@ -11,13 +11,16 @@
    The value must be a constant expression, not (for example) a variable, a
    class member, result of a mathematical operation or a function call.
   </para>
-
+  <para>
+   Its also possible for interfaces to have <literal>constants</literal>. Look at 
+   the <link linkend="language.oop5.interfaces">interface documentation</link> for 
+   examples.
+  </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>
-
   <example>
    <title>Defining and using a constant</title>
    <programlisting role="php">
@@ -64,13 +67,11 @@
     Unlike heredocs, nowdocs can be used in any static data context.
    </para>
   </example>
-
   <note>
    <para>
     Nowdoc support was added in PHP 5.3.0.
    </para>
   </note>
-   
  </sect1>
  
 <!-- Keep this comment at the end of the file
http://cvs.php.net/viewvc.cgi/phpdoc/en/language/oop5/interfaces.xml?r1=1.13&r2=1.14&diff_format=u
Index: phpdoc/en/language/oop5/interfaces.xml
diff -u phpdoc/en/language/oop5/interfaces.xml:1.13 phpdoc/en/language/oop5/interfaces.xml:1.14
--- phpdoc/en/language/oop5/interfaces.xml:1.13	Tue Aug 12 00:18:44 2008
+++ phpdoc/en/language/oop5/interfaces.xml	Tue Aug 12 21:26:21 2008
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.13 $ -->
+<!-- $Revision: 1.14 $ -->
  <sect1 xml:id="language.oop5.interfaces" xmlns="http://docbook.org/ns/docbook">
   <title>Object Interfaces</title>
   <para>
@@ -37,6 +37,14 @@
     </para>
    </note>
   </sect2>
+  <sect2 xml:id="language.oop5.interfaces.constants">
+   <title><literal>Constants</literal></title>
+   <para>
+    Its possible for interfaces to have constants. Interface constants works exactly 
+    like <link linkend="language.oop5.constants">class constants</link>. They cannot 
+    be overridden by a class/interface that inherits it.
+   </para>
+  </sect2>
   <sect2 xml:id="language.oop5.interfaces.examples">
    &reftitle.examples;
    <example xml:id="language.oop5.interfaces.examples.ex1">
@@ -157,12 +165,10 @@
     {
     }
 
-    
     public function bar()
     {
     }
 
-    
     public function baz()
     {
     }
@@ -171,6 +177,31 @@
 ]]>
      </programlisting>
    </example>
+   <example xml:id="language.oop5.interfaces.examples.ex4">
+    <title>Interfaces with constants</title>
+     <programlisting role="php">
+<![CDATA[
+<?php
+interface a
+{
+    const b = 'Interface constant';
+}
+
+// Prints: Interface constant
+echo a::b;
+
+
+// This will however not work because its not allowed to 
+// override constants. This is the same concept as with 
+// class constants
+class b implements a
+{
+    const b = 'Class constant';
+}
+?>
+]]>
+     </programlisting>
+   </example>
    <simpara>
      See also the <link linkend="language.operators.type">instanceof</link>
      operator.


Navigate in group php.doc.cvs at sever news.php.net
Previous Next




  
© No Copyright
You are free to use Anything
Site Maintained by Zareef Ahmed
Powered By PHP Consultants