<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://www.jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://www.jackxiang.com/post//</link>
<title><![CDATA[类与对象(PHP5)之五：抽象类]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Wed, 25 Oct 2006 14:58:22 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	类与对象(PHP5)之五：抽象类(Class Abstraction)<br/>PHP 5中引入了抽象类和抽象方法。不允许创建一个已经定义为abstract的类的一个实例。任何至少包含一个抽象方法的类也必须是抽象的。被定义为抽象的方法仅仅是声明方法的一个信号，并不能定义它们的实现。<br/>当从一个抽象类继承时，在父类中所有抽象方法的标记的声明必须通过子类定义；另外，这些方法必须用定义相同的访问属性。例如，如果方法被定义为protected类型，执行函数必须定义为protected或public.<br/>例子 19-16. 抽象类例子<br/><br/><br/>PHP代码如下:<br/><br/><?php<br/>abstract class AbstractClass<br/>&#123; &nbsp; // Force Extending class to define this method<br/> &nbsp; &nbsp;abstract protected function getValue();<br/> &nbsp; &nbsp;abstract protected function prefixValue($prefix);<br/> &nbsp; &nbsp;public function printOut() &nbsp;// Common method<br/> &nbsp; &nbsp;&#123; &nbsp; <br/> &nbsp; &nbsp; &nbsp; &nbsp;print $this->getValue()."&#92;n";<br/> &nbsp; &nbsp;&#125;<br/>&#125;<br/>class ConcreteClass1 extends AbstractClass<br/>&#123; &nbsp; protected function getValue()<br/> &nbsp; &nbsp;&#123; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp;return "ConcreteClass1"; &nbsp;<br/> &nbsp; &nbsp;&#125;<br/> &nbsp; &nbsp;public function prefixValue($prefix)<br/> &nbsp; &nbsp;&#123; <br/> &nbsp; &nbsp; &nbsp; &nbsp;return "&#123;$prefix&#125;ConcreteClass1"; <br/> &nbsp; &nbsp;&#125;<br/>&#125;<br/>class ConcreteClass2 extends AbstractClass<br/>&#123; &nbsp; public function getValue()<br/> &nbsp; &nbsp;&#123; &nbsp;<br/> &nbsp; &nbsp; &nbsp; &nbsp;return "ConcreteClass2"; &nbsp;<br/> &nbsp; &nbsp;&#125;<br/> &nbsp; &nbsp;public function prefixValue($prefix)<br/> &nbsp; &nbsp;&#123; <br/> &nbsp; &nbsp; &nbsp; &nbsp;return"&#123;$prefix&#125;ConcreteClass2";<br/> &nbsp; &nbsp;&#125;<br/>&#125;<br/>$class1 = new ConcreteClass1;<br/>$class1->printOut();<br/>echo $class1->prefixValue('FOO_') ."&#92;n";<br/>$class2 = new ConcreteClass2;<br/>$class2->printOut();<br/>echo $class2->prefixValue('FOO_') ."&#92;n";<br/>?> <br/><br/><br/>上例将输出：<br/><br/><br/>CODE:<br/>ConcreteClass1<br/>FOO_ConcreteClass1<br/>ConcreteClass2<br/>FOO_ConcreteClass2<br/><br/>旧代码拥有非用户自定义的命名为abstract的类或函数将要运行如果没有被修改
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] 类与对象(PHP5)之五：抽象类]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>