sean Wed Aug 3 12:13:34 2005 EDT
Modified files: /phpdoc/en/language/oop5 abstract.xml Log: improve example: add signature for method with a parameter; show example output http://cvs.php.net/diff.php/phpdoc/en/language/oop5/abstract.xml?r1=1.11&r2=1.12&ty=u Index: phpdoc/en/language/oop5/abstract.xml diff -u phpdoc/en/language/oop5/abstract.xml:1.11 phpdoc/en/language/oop5/abstract.xml:1.12 --- phpdoc/en/language/oop5/abstract.xml:1.11 Wed Aug 3 12:06:08 2005 +++ phpdoc/en/language/oop5/abstract.xml Wed Aug 3 12:13:32 2005 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.11 $ --> +<!-- $Revision: 1.12 $ --> <sect1 id="language.oop5.abstract"> <title>Class Abstraction</title> @@ -29,10 +29,11 @@ { // Force Extending class to define this method abstract protected function getValue(); + abstract protected function prefixValue($prefix); // Common method public function printOut() { - print $this->getValue(); + print $this->getValue() . "\n"; } } @@ -41,6 +42,10 @@ protected function getValue() { return "ConcreteClass1"; } + + public function prefixValue($prefix) { + return "{$prefix}ConcreteClass1"; + } } class ConcreteClass2 extends AbstractClass @@ -49,16 +54,30 @@ return "ConcreteClass2"; } + public function prefixValue($prefix) { + return "{$prefix}ConcreteClass2"; + } } $class1 = new ConcreteClass1; $class1->printOut(); +echo $class1->prefixValue('FOO_') ."\n"; $class2 = new ConcreteClass2; $class2->printOut(); +echo $class2->prefixValue('FOO_') ."\n"; ?> ]]> </programlisting> + &example.outputs; + <screen> +<![CDATA[ +ConcreteClass1 +FOO_ConcreteClass1 +ConcreteClass2 +FOO_ConcreteClass2 +]]> + </screen> </example> <para>