{"id":153,"title":"\u62bd\u8c61\u7c7b\uff0cabstract\u7c7b","good":0,"bad":0,"hit":1870,"created_at":"2015-01-12 16:24:41","content":"
\u62bd\u8c61\u7c7b\uff1a\u5305\u542b\u4e86\u62bd\u8c61\u65b9\u6cd5\u7684\u7c7b\u79f0\u4e4b\u4e3a\u62bd\u8c61\u7c7b\uff0c\u4e0d\u80fd\u7528\u4e8e\u5b9e\u4f8b\u5316\u5bf9\u8c61\uff0c\u53ea\u80fd\u88ab\u7ee7\u627f\uff01<\/strong><\/p> \u5982\uff1a<\/strong><\/p> <?php \u4e0d\u5b8c\u6574\u7684\u65b9\u6cd5\uff0c\u4e5f\u53eb\u62bd\u8c61\u65b9\u6cd5\uff0c\u6307\u7684\u662f\u6ca1\u6709\u65b9\u6cd5\u4f53\u7684\u65b9\u6cd5\uff0c\u79f0\u4e4b\u4e3a\u53ea\u6709\u65b9\u6cd5\u7684\u58f0\u660e\uff0c\u800c\u6ca1\u6709\u65b9\u6cd5\u7684\u5b9e\u73b0\u7684\u65b9\u6cd5\u79f0\u4e4b\u4e3a\u62bd\u8c61\u65b9\u6cd5\u3002\u4e5f\u5c31\u662f\u4e0d\u5b8c\u6574\u7684\u65b9\u6cd5\uff01<\/p> \u9700\u8981\u4f7f\u7528\u5173\u952e\u5b57 abstract\u6765\u58f0\u660e\u8fd9\u4e2a\u62bd\u8c61\u65b9\u6cd5\u4e0e\u62bd\u8c61\u7c7b\uff01<\/p> \u4e0d\u80fd\u5b9e\u4f8b\u5316\u5bf9\u8c61<\/strong><\/p> \u6ce8\u610f\uff1a\u62bd\u8c61\u7c7b\u662f\u53ef\u4ee5\u5305\u542b\u5176\u4ed6\u4efb\u4f55\u6b63\u5e38\u7684\u6210\u5458\u7684\uff0c\u5728\u6b64\u57fa\u7840\u4e0a\uff0c\u589e\u52a0\u4e86\u5185\u90e8\u7684\u62bd\u8c61\u65b9\u6cd5\uff01<\/p> \uff08\u5e76\u4e0d\u662f\u62bd\u8c61\u7c7b\u4e2d\u53ea\u80fd\u5305\u542b\u62bd\u8c61\u65b9\u6cd5\uff09<\/p> <?php <\/p> \u53ea\u80fd\u88ab\u7ee7\u627f<\/strong><\/p> \u4f46\u662f\uff0c\u7ee7\u627f\u65f6\uff0c\u8981\u6c42\uff0c\u5982\u679c\u5b50\u7c7b\u4e0d\u662f\u62bd\u8c61\u7c7b\uff0c\u90a3\u4e48\u7ee7\u627f\u7684\u62bd\u8c61\u65b9\u6cd5\uff0c\u8981\u88ab\u5b9e\u73b0\uff08\u88ab\u52a0\u4e0a\u65b9\u6cd5\u4f53\uff09\u624d\u53ef\u4ee5\uff01<\/p> <?php \u4f7f\u7528\u610f\u4e49<\/strong><\/p> \u53ef\u89c1\uff0c\u62bd\u8c61\u7c7b\uff0c\u53ef\u4ee5\u89c4\u5b9a\u5176\u975e\u62bd\u8c61\u5b50\u7c7b\uff0c\u5fc5\u987b\u8981\u5b58\u5728\u7684\u76f8\u5e94\u6210\u5458\u65b9\u6cd5\uff01<\/p> \u53ef\u4ee5\u89c4\u5b9a\uff0c\u5b50\u7c7b\u4e2d\u90fd\u5fc5\u987b\u5b58\u5728\uff0c\u4f46\u662f\u53ef\u4ee5\u4e0d\u540c\u7684\u65b9\u6cd5\uff01<\/p> \u62bd\u8c61\uff1aabstract\uff0c\u4e0d\u5b8c\u6574\u7684\u610f\u601d\uff01<\/p> \u5b9e\u73b0\uff1aimplement\u3002\u5c06\u65b9\u6cd5\u5b8c\u6574\u5316\uff01<\/p>
abstract class a{
abstract function f1();\/\/\u6ca1\u6709\u51fd\u6570\u4f53
}
?><\/strong>
<\/p>
<\/p>
abstract class a{
abstract function f1();\/\/\u6ca1\u6709\u51fd\u6570\u4f53
}
$o=new a();\/\/Fatal error: Cannot instantiate abstract class a
?><\/p>
abstract class a{
abstract function f1();\/\/\u6ca1\u6709\u65b9\u6cd5\u4f53
}
class b extends a{
\/\/\u7ee7\u627f\u62bd\u50cf\u7c7b\u540e\uff0c\u5fc5\u987b\u5b9e\u73b0\u5176\u62bd\u8c61\u65b9\u6cd5\uff0c\u5426\u5219\u4f1a\u62a5\u9519
public function f1(){
echo 'implement a abstract function';
}
}
$o=new b();
$o->f1();\/\/implement a abstract function
?><\/p>
<\/p>
<\/p>
<\/p>"}