jellybob Fri Jul 23 14:16:04 2004 EDT
Modified files:
/phpdoc/en/language/oop5 final.xml
Log:
Created a reference on using the final keyword.
http://cvs.php.net/diff.php/phpdoc/en/language/oop5/final.xml?r1=1.1&r2=1.2&ty=u
Index: phpdoc/en/language/oop5/final.xml
diff -u phpdoc/en/language/oop5/final.xml:1.1 phpdoc/en/language/oop5/final.xml:1.2
--- phpdoc/en/language/oop5/final.xml:1.1 Sun Jul 11 08:33:25 2004
+++ phpdoc/en/language/oop5/final.xml Fri Jul 23 14:16:04 2004
@@ -1,11 +1,37 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
<sect1 id="language.oop5.final">
<title>Final Keyword</title>
<para>
- .
+ PHP 5 introduces the final keyword, which prevents child classes from
+ overriding a method or variable by prefixing the definition with final.
</para>
+
+ <example>
+ <title>Abstract class example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+class BaseClass {
+ public function test() {
+ echo "BaseClass::test() called\n";
+ }
+
+ final public function moreTesting() {
+ echo "BaseClass::moreTesting() called\n";
+ }
+}
+class ChildClass extends BaseClass {
+ public function moreTesting() {
+ echo "ChildClass::moreTesting() called\n";
+ }
+}
+// Results in Fatal error: Cannot override final method BaseClass::moreTesting()
+?>
+]]>
+ </programlisting>
+ </example>
</sect1>