{"id":900,"date":"2019-08-02T12:32:59","date_gmt":"2019-08-02T04:32:59","guid":{"rendered":"https:\/\/wyxxt.org.cn\/?p=900"},"modified":"2023-12-04T16:46:47","modified_gmt":"2023-12-04T08:46:47","slug":"php-%e6%8a%bd%e8%b1%a1%e7%b1%bbabstract-class%e5%92%8c%e6%8e%a5%e5%8f%a3interface","status":"publish","type":"post","link":"https:\/\/wyxxt.org.cn\/?p=900","title":{"rendered":"php-\u62bd\u8c61\u7c7b(abstract class)\u548c\u63a5\u53e3(interface)"},"content":{"rendered":"<h3>\u62bd\u8c61\u7c7b abstract class<\/h3>\n<ol>\n<li>\u62bd\u8c61\u7c7b\u662f\u6307\u5728 class \u524d\u52a0\u4e86 abstract \u5173\u952e\u5b57\u4e14\u5b58\u5728\u62bd\u8c61\u65b9\u6cd5\uff08\u5728\u7c7b\u65b9\u6cd5 function \u5173\u952e\u5b57\u524d\u52a0\u4e86 abstract \u5173\u952e\u5b57\uff09\u7684\u7c7b\u3002<\/p>\n<\/li>\n<li>\n<p>\u62bd\u8c61\u7c7b\u4e0d\u80fd\u88ab\u76f4\u63a5\u5b9e\u4f8b\u5316\u3002\u62bd\u8c61\u7c7b\u4e2d\u53ea\u5b9a\u4e49\uff08\u6216\u90e8\u5206\u5b9e\u73b0\uff09\u5b50\u7c7b\u9700\u8981\u7684\u65b9\u6cd5\u3002\u5b50\u7c7b\u53ef\u4ee5\u901a\u8fc7\u7ee7\u627f\u62bd\u8c61\u7c7b\u5e76\u901a\u8fc7\u5b9e\u73b0\u62bd\u8c61\u7c7b\u4e2d\u7684\u6240\u6709\u62bd\u8c61\u65b9\u6cd5\uff0c\u4f7f\u62bd\u8c61\u7c7b\u5177\u4f53\u5316\u3002<\/p>\n<\/li>\n<li>\n<p>\u5982\u679c\u5b50\u7c7b\u9700\u8981\u5b9e\u4f8b\u5316\uff0c\u524d\u63d0\u662f\u5b83\u5b9e\u73b0\u4e86\u62bd\u8c61\u7c7b\u4e2d\u7684\u6240\u6709\u62bd\u8c61\u65b9\u6cd5\u3002\u5982\u679c\u5b50\u7c7b\u6ca1\u6709\u5168\u90e8\u5b9e\u73b0\u62bd\u8c61\u7c7b\u4e2d\u7684\u6240\u6709\u62bd\u8c61\u65b9\u6cd5\uff0c\u90a3\u4e48\u8be5\u5b50\u7c7b\u4e5f\u662f\u4e00\u4e2a\u62bd\u8c61\u7c7b\uff0c\u5fc5\u987b\u5728 class \u524d\u9762\u52a0\u4e0a abstract \u5173\u952e\u5b57\uff0c\u5e76\u4e14\u4e0d\u80fd\u88ab\u5b9e\u4f8b\u5316\u3002<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"language-php line-numbers\">abstract class A\n{\n    \/** \u62bd\u8c61\u7c7b\u4e2d\u53ef\u4ee5\u5b9a\u4e49\u53d8\u91cf *\/\n    protected $value1 = 0;\n    private $value2 = 1;\n    public $value3 = 2;\n    \/** \u4e5f\u53ef\u4ee5\u5b9a\u4e49\u975e\u62bd\u8c61\u65b9\u6cd5 *\/\n    public function my_print()\n    {\n        echo \"hello,world\/n\";\n    }\n    \/**\n     * \u5927\u591a\u6570\u60c5\u51b5\u4e0b\uff0c\u62bd\u8c61\u7c7b\u81f3\u5c11\u542b\u6709\u4e00\u4e2a\u62bd\u8c61\u65b9\u6cd5\u3002\u62bd\u8c61\u65b9\u6cd5\u7528abstract\u5173\u952e\u5b57\u58f0\u660e\uff0c\u5176\u4e2d\u4e0d\u80fd\u6709\u5177\u4f53\u5185\u5bb9\u3002\n     * \u53ef\u4ee5\u50cf\u58f0\u660e\u666e\u901a\u7c7b\u65b9\u6cd5\u90a3\u6837\u58f0\u660e\u62bd\u8c61\u65b9\u6cd5\uff0c\u4f46\u662f\u8981\u4ee5\u5206\u53f7\u800c\u4e0d\u662f\u65b9\u6cd5\u4f53\u7ed3\u675f\u3002\u4e5f\u5c31\u662f\u8bf4\u62bd\u8c61\u65b9\u6cd5\u5728\u62bd\u8c61\u7c7b\u4e2d\u4e0d\u80fd\u88ab\u5b9e\u73b0\uff0c\u4e5f\u5c31\u662f\u6ca1\u6709\u51fd\u6570\u4f53\u201c{some codes}\u201d\u3002\n     *\/\n    abstract protected function abstract_func1();\n    abstract protected function abstract_func2();\n}\nabstract class B extends A\n{\n    public function abstract_func1()\n    {\n       echo \"implement the abstract_func1 in class A\/n\";\n    }\n    \/** \u8fd9\u4e48\u5199\u5728zend studio 8\u4e2d\u4f1a\u62a5\u9519*\/\n    \/\/abstract protected function abstract_func2();\n}\nclass C extends B\n{\n    public function abstract_func2()\n    {\n       echo \"implement the abstract_func2 in class A\/n\";\n    }\n}\n<\/code><\/pre>\n<ol start=\"4\">\n<li>\u5982\u679c\u50cf\u4e0b\u9762\u8fd9\u6837\u521b\u5efa\u4e86\u4e00\u4e2a\u7ee7\u627f\u81ea A \u7684\u5b50\u7c7b B \uff0c\u4f46\u662f\u4e0d\u5b9e\u73b0\u62bd\u8c61\u65b9\u6cd5 abstract_func() \uff1a<\/li>\n<\/ol>\n<pre><code class=\"language-php line-numbers\">Class B extends A{};\n<\/code><\/pre>\n<p>\u90a3\u4e48\u7a0b\u5e8f\u5c06\u51fa\u73b0\u4ee5\u4e0b\u9519\u8bef\uff1a<\/p>\n<pre><code class=\"line-numbers\">Fatal error: Class B contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (A::abstract_func)\n<\/code><\/pre>\n<ol start=\"5\">\n<li>\u5982\u679c B \u5b9e\u73b0\u4e86\u62bd\u8c61\u65b9\u6cd5 abstract_func() \uff0c\u90a3\u4e48 B \u4e2d abstract_func() \u65b9\u6cd5\u7684\u8bbf\u95ee\u63a7\u5236\u4e0d\u80fd\u6bd4 A \u4e2d abstract_func() \u7684\u8bbf\u95ee\u63a7\u5236\u66f4\u4e25\u683c\uff0c\u4e5f\u5c31\u662f\u8bf4\uff1a\n<p>(1) \u5982\u679c A \u4e2d abstract_func() \u58f0\u660e\u4e3a public \uff0c\u90a3\u4e48 B \u4e2d abstract_func() \u7684\u58f0\u660e\u53ea\u80fd\u662f public \uff0c\u4e0d\u80fd\u662f protected \u6216 private<\/p>\n<p>(2) \u5982\u679c A \u4e2d abstract_func() \u58f0\u660e\u4e3a protected \uff0c\u90a3\u4e48 B \u4e2d abstract_func() \u7684\u58f0\u660e\u53ef\u4ee5\u662f public \u6216 protected \uff0c\u4f46\u4e0d\u80fd\u662f private<\/p>\n<p>(3) \u5982\u679c A \u4e2d abstract_func() \u58f0\u660e\u4e3a private \uff0c\u563f\u563f\uff0c\u4e0d\u80fd\u5b9a\u4e49\u4e3a private \u54e6\uff01\uff08 Fatal error : Abstract function A::abstract_func() cannot be declared private \uff09<\/p>\n<\/li>\n<\/ol>\n<h3>\u63a5\u53e3interface<\/h3>\n<ol>\n<li>\n<p>\u62bd\u8c61\u7c7b\u63d0\u4f9b\u4e86\u5177\u4f53\u5b9e\u73b0\u7684\u6807\u51c6\uff0c\u800c\u63a5\u53e3\u5219\u662f\u7eaf\u7cb9\u7684\u6a21\u7248\u3002\u63a5\u53e3\u53ea\u5b9a\u4e49\u529f\u80fd\uff0c\u800c\u4e0d\u5305\u542b\u5b9e\u73b0\u7684\u5185\u5bb9\u3002\u63a5\u53e3\u7528\u5173\u952e\u5b57 interface \u6765\u58f0\u660e\u3002<\/p>\n<\/li>\n<li>\n<p>interface \u662f\u5b8c\u5168\u62bd\u8c61\u7684\uff0c\u53ea\u80fd\u58f0\u660e\u65b9\u6cd5\uff0c\u800c\u4e14\u53ea\u80fd\u58f0\u660e public \u7684\u65b9\u6cd5\uff0c\u4e0d\u80fd\u58f0\u660e private \u53ca protected \u7684\u65b9\u6cd5\uff0c\u4e0d\u80fd\u5b9a\u4e49\u65b9\u6cd5\u4f53\uff0c\u4e5f\u4e0d\u80fd\u58f0\u660e\u5b9e\u4f8b\u53d8\u91cf \u3002\u7136\u800c\uff0c interface \u5374\u53ef\u4ee5\u58f0\u660e\u5e38\u91cf\u53d8\u91cf \u3002\u4f46\u5c06\u5e38\u91cf\u53d8\u91cf\u653e\u5728 interface \u4e2d\u8fdd\u80cc\u4e86\u5176\u4f5c\u4e3a\u63a5\u53e3\u7684\u4f5c\u7528\u800c\u5b58\u5728\u7684\u5b97\u65e8\uff0c\u4e5f\u6df7\u6dc6\u4e86 interface \u4e0e\u7c7b\u7684\u4e0d\u540c\u4ef7\u503c\u3002\u5982\u679c\u7684\u786e\u9700\u8981\uff0c\u53ef\u4ee5\u5c06\u5176\u653e\u5728\u76f8\u5e94\u7684 abstract class \u6216 Class \u4e2d\u3002<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"language-php line-numbers\">interface iA\n{\n    const AVAR=3;\n    public function iAfunc1();\n    public function iAfunc2();\n}\necho iA::AVAR;\n<\/code><\/pre>\n<ol start=\"3\">\n<li>\u4efb\u4f55\u5b9e\u73b0\u63a5\u53e3\u7684\u7c7b\u90fd\u8981\u5b9e\u73b0\u63a5\u53e3\u4e2d\u6240\u5b9a\u4e49\u7684\u6240\u6709\u65b9\u6cd5<\/li>\n<\/ol>\n<pre><code class=\"language-php line-numbers\">class E implements iA\n{\n    public function iAfunc1(){echo \"in iAfunc1\";}\n    public function iAfunc2(){echo \"in iAfunc2\";}\n}\n<\/code><\/pre>\n<p>\u5426\u5219\u8be5\u7c7b\u5fc5\u987b\u58f0\u660e\u4e3a abstract \u3002<\/p>\n<pre><code class=\"language-php line-numbers\">abstract class E implements iA{}\n<\/code><\/pre>\n<ol start=\"4\">\n<li>\u4e00\u4e2a\u7c7b\u53ef\u4ee5\u5728\u58f0\u660e\u4e2d\u4f7f\u7528 implements \u5173\u952e\u5b57\u6765\u5b9e\u73b0\u67d0\u4e2a\u63a5\u53e3\u3002\u8fd9\u4e48\u505a\u4e4b\u540e\uff0c\u5b9e\u73b0\u63a5\u53e3\u7684\u5177\u4f53\u8fc7\u7a0b\u548c\u7ee7\u627f\u4e00\u4e2a\u4ec5\u5305\u542b\u62bd\u8c61\u65b9\u6cd5\u7684\u62bd\u8c61\u7c7b\u662f\u4e00\u6837\u7684\u3002\u4e00\u4e2a\u7c7b\u53ef\u4ee5\u540c\u65f6\u7ee7\u627f\u4e00\u4e2a\u7236\u7c7b\u548c\u5b9e\u73b0\u4efb\u610f\u591a\u4e2a\u63a5\u53e3\u3002 extends \u5b50\u53e5\u5e94\u8be5\u5728 implements \u5b50\u53e5\u4e4b\u524d\u3002 PHP \u53ea\u652f\u6301\u7ee7\u627f\u81ea\u4e00\u4e2a\u7236\u7c7b\uff0c\u56e0\u6b64 extends \u5173\u952e\u5b57\u540e\u53ea\u80fd\u8ddf\u4e00\u4e2a\u7c7b\u540d\u3002<\/li>\n<\/ol>\n<pre><code class=\"language-php line-numbers\">interface iB\n{\n    public function iBfunc1();\n    public function iBfunc2();\n}\nclass D extends A implements iA,iB\n{\n    public function abstract_func1()\n    {\n       echo \"implement the abstract_func1 in class A\/n\";\n    }\n    public function abstract_func2()\n    {\n       echo \"implement the abstract_func2 in class A\/n\";\n    }\n    public function iAfunc1(){echo \"in iAfunc1\";}\n    public function iAfunc2(){echo \"in iAfunc2\";}\n    public function iBfunc1(){echo \"in iBfunc1\";}\n    public function iBfunc2(){echo \"in iBfunc2\";}\n}\n\nclass D extends B implements iA,iB\n{\n    public function abstract_func1()\n    {\n       parent::abstract_func1();\n       echo \"override the abstract_func1 in class A\/n\";\n    }\n    public function abstract_func2()\n    {\n       echo \"implement the abstract_func2 in class A\/n\";\n    }\n    public function iAfunc1(){echo \"in iAfunc1\";}\n    public function iAfunc2(){echo \"in iAfunc2\";}\n    public function iBfunc1(){echo \"in iBfunc1\";}\n    public function iBfunc2(){echo \"in iBfunc2\";}\n}\n<\/code><\/pre>\n<ol start=\"5\">\n<li>\u63a5\u53e3\u4e0d\u53ef\u4ee5\u5b9e\u73b0\u53e6\u4e00\u4e2a\u63a5\u53e3\uff0c\u4f46\u53ef\u4ee5\u7ee7\u627f\u591a\u4e2a<\/li>\n<\/ol>\n<pre><code class=\"language-php line-numbers\">interface iC extends iA,iB{}\nclass F implements iC\n{\n    public function iAfunc1(){echo \"in iAfunc1\";}\n    public function iAfunc2(){echo \"in iAfunc2\";}\n    public function iBfunc1(){echo \"in iBfunc1\";}\n    public function iBfunc2(){echo \"in iBfunc2\";}\n}\n<\/code><\/pre>\n<h3>\u62bd\u8c61\u7c7b\u548c\u63a5\u53e3\u7684\u5f02\u540c<\/h3>\n<ol>\n<li>\u76f8\u540c\u70b9\uff1a\n<p>(1) \u4e24\u8005\u90fd\u662f\u62bd\u8c61\u7c7b\uff0c\u90fd\u4e0d\u80fd\u5b9e\u4f8b\u5316\u3002<\/p>\n<p>(2)\u00a0interface \u5b9e\u73b0\u7c7b\u53ca abstract class \u7684\u5b50\u7c7b\u90fd\u5fc5\u987b\u8981\u5b9e\u73b0\u5df2\u7ecf\u58f0\u660e\u7684\u62bd\u8c61\u65b9\u6cd5\u3002<\/p>\n<\/li>\n<li>\n<p>\u4e0d\u540c\u70b9\uff1a<\/p>\n<p>(1)\u00a0\u00a0\u00a0\u00a0\u00a0 interface \u9700\u8981\u5b9e\u73b0\uff0c\u8981\u7528 implements \uff0c\u800c abstract class \u9700\u8981\u7ee7\u627f\uff0c\u8981\u7528 extends \u3002<\/p>\n<p>(2)\u00a0\u00a0\u00a0\u00a0\u00a0 \u4e00\u4e2a\u7c7b\u53ef\u4ee5\u5b9e\u73b0\u591a\u4e2a interface \uff0c\u4f46\u4e00\u4e2a\u7c7b\u53ea\u80fd\u7ee7\u627f\u4e00\u4e2a abstract class \u3002<\/p>\n<p>(3)\u00a0\u00a0\u00a0\u00a0\u00a0 interface \u5f3a\u8c03\u7279\u5b9a\u529f\u80fd\u7684\u5b9e\u73b0\uff0c\u800c abstract class \u5f3a\u8c03\u6240\u5c5e\u5173\u7cfb\u3002<\/p>\n<p>(4)\u00a0\u00a0\u00a0\u00a0\u00a0 \u5c3d\u7ba1 interface \u5b9e\u73b0\u7c7b\u53ca abstract class \u7684\u5b50\u7c7b\u90fd\u5fc5\u987b\u8981\u5b9e\u73b0\u76f8\u5e94\u7684\u62bd\u8c61\u65b9\u6cd5\uff0c\u4f46\u5b9e\u73b0\u7684\u5f62\u5f0f\u4e0d\u540c\u3002 interface \u4e2d\u7684\u6bcf\u4e00\u4e2a\u65b9\u6cd5\u90fd\u662f\u62bd\u8c61\u65b9\u6cd5\uff0c\u90fd\u53ea\u662f\u58f0\u660e\u7684 (declaration, \u6ca1\u6709\u65b9\u6cd5\u4f53 ) \uff0c\u5b9e\u73b0\u7c7b\u5fc5\u987b\u8981\u5b9e\u73b0\u3002\u800c abstract class \u7684\u5b50\u7c7b\u53ef\u4ee5\u6709\u9009\u62e9\u5730\u5b9e\u73b0\u3002\u8fd9\u4e2a\u9009\u62e9\u6709\u4e24\u70b9\u542b\u4e49\uff1a a) abstract class \u4e2d\u5e76\u975e\u6240\u6709\u7684\u65b9\u6cd5\u90fd\u662f\u62bd\u8c61\u7684\uff0c\u53ea\u6709\u90a3\u4e9b\u51a0\u6709 abstract \u7684\u65b9\u6cd5\u624d\u662f\u62bd\u8c61\u7684\uff0c\u5b50\u7c7b\u5fc5\u987b\u5b9e\u73b0\u3002\u90a3\u4e9b\u6ca1\u6709 abstract \u7684\u65b9\u6cd5\uff0c\u5728 abstract class \u4e2d\u5fc5\u987b\u5b9a\u4e49\u65b9\u6cd5\u4f53\uff1b b) abstract class \u7684\u5b50\u7c7b\u5728\u7ee7\u627f\u5b83\u65f6\uff0c\u5bf9\u975e\u62bd\u8c61\u65b9\u6cd5\u65e2\u53ef\u4ee5\u76f4\u63a5\u7ee7\u627f\uff0c\u4e5f\u53ef\u4ee5\u8986\u76d6\uff1b\u800c\u5bf9\u62bd\u8c61\u65b9\u6cd5\uff0c\u53ef\u4ee5\u9009\u62e9\u5b9e\u73b0\uff0c\u4e5f\u53ef\u4ee5\u7559\u7ed9\u5176\u5b50\u7c7b\u6765\u5b9e\u73b0\uff0c\u4f46\u6b64\u7c7b\u5fc5\u987b\u4e5f\u58f0\u660e\u4e3a\u62bd\u8c61\u7c7b\u3002\u65e2\u662f\u62bd\u8c61\u7c7b\uff0c\u5f53\u7136\u4e5f\u4e0d\u80fd\u5b9e\u4f8b\u5316\u3002<\/p>\n<p>(5)\u00a0\u00a0\u00a0\u00a0\u00a0 abstract class \u662f interface \u4e0e class \u7684\u4e2d\u4ecb\u3002 abstract class \u5728 interface \u53ca class \u4e2d\u8d77\u5230\u4e86\u627f\u4e0a\u542f\u4e0b\u7684\u4f5c\u7528\u3002\u4e00\u65b9\u9762\uff0c abstract class \u662f\u62bd\u8c61\u7684\uff0c\u53ef\u4ee5\u58f0\u660e\u62bd\u8c61\u65b9\u6cd5\uff0c\u4ee5\u89c4\u8303\u5b50\u7c7b\u5fc5\u987b\u5b9e\u73b0\u7684\u529f\u80fd\uff1b\u53e6\u4e00\u65b9\u9762\uff0c\u5b83\u53c8\u53ef\u4ee5\u5b9a\u4e49\u7f3a\u7701\u7684\u65b9\u6cd5\u4f53\uff0c\u4f9b\u5b50\u7c7b\u76f4\u63a5\u4f7f\u7528\u6216\u8986\u76d6\u3002\u53e6\u5916\uff0c\u5b83\u8fd8\u53ef\u4ee5\u5b9a\u4e49\u81ea\u5df1\u7684\u5b9e\u4f8b\u53d8\u91cf\uff0c\u4ee5\u4f9b\u5b50\u7c7b\u901a\u8fc7\u7ee7\u627f\u6765\u4f7f\u7528\u3002<\/p>\n<p>(6)\u00a0\u00a0\u00a0\u00a0\u00a0 \u63a5\u53e3\u4e2d\u7684\u62bd\u8c61\u65b9\u6cd5\u524d\u4e0d\u7528\u4e5f\u4e0d\u80fd\u52a0 abstract \u5173\u952e\u5b57\uff0c\u9ed8\u8ba4\u9690\u5f0f\u5c31\u662f\u62bd\u8c61\u65b9\u6cd5\uff0c\u4e5f\u4e0d\u80fd\u52a0 final \u5173\u952e\u5b57\u6765\u9632\u6b62\u62bd\u8c61\u65b9\u6cd5\u7684\u7ee7\u627f\u3002\u800c\u62bd\u8c61\u7c7b\u4e2d\u62bd\u8c61\u65b9\u6cd5\u524d\u5219\u5fc5\u987b\u52a0\u4e0a abstract \u8868\u793a\u663e\u793a\u58f0\u660e\u4e3a\u62bd\u8c61\u65b9\u6cd5\u3002<\/p>\n<p>(7)\u00a0\u00a0\u00a0\u00a0\u00a0 \u63a5\u53e3\u4e2d\u7684\u62bd\u8c61\u65b9\u6cd5\u9ed8\u8ba4\u662f public \u7684\uff0c\u4e5f\u53ea\u80fd\u662f public \u7684\uff0c\u4e0d\u80fd\u7528 private \uff0c protected \u4fee\u9970\u7b26\u4fee\u9970\u3002\u800c\u62bd\u8c61\u7c7b\u4e2d\u7684\u62bd\u8c61\u65b9\u6cd5\u5219\u53ef\u4ee5\u7528 public \uff0c protected \u6765\u4fee\u9970\uff0c\u4f46\u4e0d\u80fd\u7528 private \u3002<\/p>\n<\/li>\n<li>\n<p>interface \u7684\u5e94\u7528\u573a\u5408<\/p>\n<p>(1)\u00a0\u00a0\u00a0\u00a0\u00a0 \u7c7b\u4e0e\u7c7b\u4e4b\u95f4\u9700\u8981\u7279\u5b9a\u7684\u63a5\u53e3\u8fdb\u884c\u534f\u8c03\uff0c\u800c\u4e0d\u5728\u4e4e\u5176\u5982\u4f55\u5b9e\u73b0\u3002<\/p>\n<p>(2)\u00a0\u00a0\u00a0\u00a0\u00a0 \u4f5c\u4e3a\u80fd\u591f\u5b9e\u73b0\u7279\u5b9a\u529f\u80fd\u7684\u6807\u8bc6\u5b58\u5728\uff0c\u4e5f\u53ef\u4ee5\u662f\u4ec0\u4e48\u63a5\u53e3\u65b9\u6cd5\u90fd\u6ca1\u6709\u7684\u7eaf\u7cb9\u6807\u8bc6\u3002<\/p>\n<p>(3)\u00a0\u00a0\u00a0\u00a0\u00a0 \u9700\u8981\u5c06\u4e00\u7ec4\u7c7b\u89c6\u4e3a\u5355\u4e00\u7684\u7c7b\uff0c\u800c\u8c03\u7528\u8005\u53ea\u901a\u8fc7\u63a5\u53e3\u6765\u4e0e\u8fd9\u7ec4\u7c7b\u53d1\u751f\u8054\u7cfb\u3002<\/p>\n<p>(4)\u00a0\u00a0\u00a0\u00a0\u00a0 \u9700\u8981\u5b9e\u73b0\u7279\u5b9a\u7684\u591a\u9879\u529f\u80fd\uff0c\u800c\u8fd9\u4e9b\u529f\u80fd\u4e4b\u95f4\u53ef\u80fd\u5b8c\u5168\u6ca1\u6709\u4efb\u4f55\u8054\u7cfb\u3002<\/p>\n<\/li>\n<li>\n<p>abstract class \u7684\u5e94\u7528\u573a\u5408<\/p>\n<\/li>\n<\/ol>\n<p>\u4e00\u53e5\u8bdd\uff0c\u5728\u65e2\u9700\u8981\u7edf\u4e00\u7684\u63a5\u53e3\uff0c\u53c8\u9700\u8981\u5b9e\u4f8b\u53d8\u91cf\u6216\u7f3a\u7701\u7684\u65b9\u6cd5\u7684\u60c5\u51b5\u4e0b\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528\u5b83\u3002\u6700\u5e38\u89c1\u7684\u6709\uff1a<\/p>\n<p>(1)\u00a0\u00a0\u00a0\u00a0\u00a0 \u5b9a\u4e49\u4e86\u4e00\u7ec4\u63a5\u53e3\uff0c\u4f46\u53c8\u4e0d\u60f3\u5f3a\u8feb\u6bcf\u4e2a\u5b9e\u73b0\u7c7b\u90fd\u5fc5\u987b\u5b9e\u73b0\u6240\u6709\u7684\u63a5\u53e3\u3002\u53ef\u4ee5\u7528 abstract class \u5b9a\u4e49\u4e00\u7ec4\u65b9\u6cd5\u4f53\uff0c\u751a\u81f3\u53ef\u4ee5\u662f\u7a7a\u65b9\u6cd5\u4f53\uff0c\u7136\u540e\u7531\u5b50\u7c7b\u9009\u62e9\u81ea\u5df1\u6240\u611f\u5174\u8da3\u7684\u65b9\u6cd5\u6765\u8986\u76d6\u3002<\/p>\n<p>(2)\u00a0\u00a0\u00a0\u00a0\u00a0 \u67d0\u4e9b\u573a\u5408\u4e0b\uff0c\u53ea\u9760\u7eaf\u7cb9\u7684\u63a5\u53e3\u4e0d\u80fd\u6ee1\u8db3\u7c7b\u4e0e\u7c7b\u4e4b\u95f4\u7684\u534f\u8c03\uff0c\u8fd8\u5fc5\u9700\u7c7b\u4e2d\u8868\u793a\u72b6\u6001\u7684\u53d8\u91cf\u6765\u533a\u522b\u4e0d\u540c\u7684\u5173\u7cfb\u3002 abstract \u7684\u4e2d\u4ecb\u4f5c\u7528\u53ef\u4ee5\u5f88\u597d\u5730\u6ee1\u8db3\u8fd9\u4e00\u70b9\u3002<\/p>\n<p>(3)\u00a0\u00a0\u00a0\u00a0\u00a0 \u89c4\u8303\u4e86\u4e00\u7ec4\u76f8\u4e92\u534f\u8c03\u7684\u65b9\u6cd5\uff0c\u5176\u4e2d\u4e00\u4e9b\u65b9\u6cd5\u662f\u5171\u540c\u7684\uff0c\u4e0e\u72b6\u6001\u65e0\u5173\u7684\uff0c\u53ef\u4ee5\u5171\u4eab\u7684\uff0c\u65e0\u9700\u5b50\u7c7b\u5206\u522b\u5b9e\u73b0\uff1b\u800c\u53e6\u4e00\u4e9b\u65b9\u6cd5\u5374\u9700\u8981\u5404\u4e2a\u5b50\u7c7b\u6839\u636e\u81ea\u5df1\u7279\u5b9a\u7684\u72b6\u6001\u6765\u5b9e\u73b0\u7279 \u5b9a\u7684\u529f\u80fd \u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u62bd\u8c61\u7c7b abstract class \u62bd\u8c61\u7c7b\u662f\u6307\u5728 class \u524d\u52a0\u4e86 abstract \u5173\u952e\u5b57\u4e14\u5b58\u5728\u62bd\u8c61\u65b9\u6cd5 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[15],"tags":[405],"class_list":["post-900","post","type-post","status-publish","format-standard","hentry","category-15","tag-php"],"_links":{"self":[{"href":"https:\/\/wyxxt.org.cn\/index.php?rest_route=\/wp\/v2\/posts\/900","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wyxxt.org.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wyxxt.org.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wyxxt.org.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wyxxt.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=900"}],"version-history":[{"count":3,"href":"https:\/\/wyxxt.org.cn\/index.php?rest_route=\/wp\/v2\/posts\/900\/revisions"}],"predecessor-version":[{"id":903,"href":"https:\/\/wyxxt.org.cn\/index.php?rest_route=\/wp\/v2\/posts\/900\/revisions\/903"}],"wp:attachment":[{"href":"https:\/\/wyxxt.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=900"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wyxxt.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=900"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wyxxt.org.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=900"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}