mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
improve example: add signature for method with a parameter; show example output
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@192321 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
b668dccf1f
commit
2a81f2c622
1 changed files with 21 additions and 2 deletions
|
@ -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 @@ abstract class AbstractClass
|
|||
{
|
||||
// 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 @@ class ConcreteClass1 extends AbstractClass
|
|||
protected function getValue() {
|
||||
return "ConcreteClass1";
|
||||
}
|
||||
|
||||
public function prefixValue($prefix) {
|
||||
return "{$prefix}ConcreteClass1";
|
||||
}
|
||||
}
|
||||
|
||||
class ConcreteClass2 extends AbstractClass
|
||||
|
@ -49,16 +54,30 @@ class ConcreteClass2 extends AbstractClass
|
|||
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>
|
||||
|
|
Loading…
Reference in a new issue