{"id":419406,"date":"2021-03-30T18:06:31","date_gmt":"2021-03-30T10:06:31","guid":{"rendered":"http:\/\/4563.org\/?p=419406"},"modified":"2021-03-30T18:06:31","modified_gmt":"2021-03-30T10:06:31","slug":"%e8%af%b7%e9%97%ae-php-%e4%b8%ad%e7%9a%84-self-%e5%85%b3%e9%94%ae%e5%ad%97%e6%8a%91%e5%88%b6%e5%a4%9a%e6%80%81%e6%98%af%e4%bb%80%e4%b9%88%e6%84%8f%e6%80%9d%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=419406","title":{"rendered":"\u8bf7\u95ee PHP \u4e2d\u7684 self:: \u5173\u952e\u5b57\u6291\u5236\u591a\u6001\u662f\u4ec0\u4e48\u610f\u601d\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8bf7\u95ee PHP \u4e2d\u7684 self:: \u5173\u952e\u5b57\u6291\u5236\u591a\u6001\u662f\u4ec0\u4e48\u610f\u601d\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wfdaj <\/span>  <span><i><\/i> 1<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u770b\u5230\u8fd9\u6837\u4e24\u53e5\u4ee3\u7801\uff1a<\/p>\n<pre><code>function __construct() {     self::openDatabaseConnection(); }  private function openDatabaseConnection()  {     \u2026\u2026 } <\/code><\/pre>\n<p>\u6211\u4ee5\u4e3a\u8fd9\u91cc\u7684 self:: \u662f\u8981\u8c03\u7528 openDatabaseConnection\uff0c\u4f46 openDatabaseConnection \u4e0d\u662f\u9759\u6001\u7684\uff0c\u800c\u4e14 vscode \u4e5f\u63d0\u793a\uff1a\u4e0d\u5e94\u9759\u6001\u8c03\u7528\u975e\u9759\u6001\u65b9\u6cd5\u201copenDatabaseConnection\u201d\u3002<\/p>\n<p>\u767e\u5ea6\u5230 <strong>self:: \u8fd8\u80fd\u6291\u5236\u591a\u6001\uff0c\u6307\u5411\u5f53\u524d\u7c7b\u7684\u6210\u5458\u51fd\u6570<\/strong>\uff0c\u8bf7\u95ee\uff0c\u8fd9\u662f\u5565\u610f\u601d\uff1f      <\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>11<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5602106\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xycc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/www.php.net\/manual\/zh\/language.oop5.late-static-bindings.php                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5602107\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jhdxr <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4ee5\u6700\u65b0\u7684 PHP \u7248\u672c\u6765\u770b\uff0c\u6211\u89c9\u5f97\u8fd9\u5c31\u662f\u4e00\u4e2a\u9519\u8bef\u7684\u5199\u6cd5\u3002\u3002\u3002\u6ca1\u5565\u6280\u5de7\u53ef\u8a00                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5602108\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : wfdaj <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @xycc \u611f\u8c22\u56de\u590d\u3002\u6587\u6863\u6ca1\u600e\u4e48\u770b\u61c2\uff0c\u641c\u7d22\u7684\u7ed3\u679c\u662f\uff0c\u7528\u4e8e\u6570\u636e\u5e93\u8fde\u63a5\u5b9e\u73b0\u5355\u4f8b\u6a21\u5f0f\u5427\u3002<br \/>@jhdxr \u597d\u5427\uff0c\u6211\u5e76\u6ca1\u6709\u770b\u61c2\u4e3a\u5565\u8981\u8fd9\u6837\u5199\u6765\u5b9e\u73b0\u5355\u4f8b\u6a21\u5f0f\u3002-_-&#8221;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5602109\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Sunyanzi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u9876\u90a3\u6bb5\u4ee3\u7801\u6beb\u65e0\u7591\u95ee\u7684\u5c31\u662f\u4e2a\u9519\u8bef &#8230; \u4e0d\u662f\u4ec0\u4e48\u9ad8\u7aef\u5199\u6cd5 &#8230;<\/p>\n<p>\u81f3\u4e8e\u6291\u5236\u591a\u6001 &#8230; \u5ef6\u9759\u7ed1\u7684\u6587\u6863\u770b\u4e0d\u61c2\u7684\u8bdd &#8230; \u8bd5\u8bd5\u770b\u80fd\u4e0d\u80fd\u770b\u61c2\u6211\u4e0b\u9762\u7684\u4ee3\u7801 &#8230; <\/p>\n<p>\u6211\u8fd9\u6bb5\u4ee3\u7801\u91cc\u5b8c\u6574\u5b9e\u73b0\u4e86\u591a\u6001\u4e09\u8981\u7d20 &#8230; \u4e5f\u6f14\u793a\u4e86 self:: \u5982\u4f55\u6291\u5236\u591a\u6001 &#8230;<\/p>\n<p>\u8bf4\u771f\u7684 &#8230; \u8bb2 OOP \u7684\u65f6\u5019\u6211\u53ef\u559c\u6b22\u4e3e\u8fd9\u79cd\u4f8b\u5b50\u4e86 &#8230; \u80fd\u660e\u767d\u6211\u5728\u5199\u4ec0\u4e48\u5c31\u597d &#8230; \u5355\u4f8b\u4e0d\u5355\u4f8b\u7684\u5b8c\u5168\u4e0d\u91cd\u8981 &#8230;<\/p>\n<p>i.imgur.com\/KB0Dvb5.png                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5602110\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : wfdaj <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Sunyanzi \u6211\u53d1\u7684\u4ee3\u7801\u5728\u8fd9\u91cc\uff1a https:\/\/github.com\/panique\/mini3\/blob\/master\/application\/Core\/Model.php<\/p>\n<p>start \u6570\u6709 200 \u591a\uff0c\u662f\u4e2a\u975e\u5e38\u5c0f\u7684\u6846\u67b6\uff0c\u96be\u9053\u8fd9\u4f1a\u662f\u4e2a\u975e\u5e38\u660e\u663e\u7684\u9519\u8bef\uff1f                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5602111\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : wfdaj <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7b2c\u4e00\u7248\u5c31\u662f &#8220;$this-&gt;openDatabaseConnection();&#8220;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5602112\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Sunyanzi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @wfdaj 200 \u591a Star \u5e76\u4e0d\u4ee3\u8868\u4f5c\u8005\u5728\u8fd9\u91cc\u5199\u5bf9\u4e86 &#8230; \u4ee5\u90a3\u4e2a\u6587\u4ef6\u7684\u5199\u6cd5\u770b\u8fd9\u91cc\u6bcb\u5eb8\u7f6e\u7591\u7684\u5e94\u8be5\u7528 $this-&gt; &#8230;<\/p>\n<p>\u4ee5\u53ca &#8230; \u6211\u6240\u6307\u7684\u9519\u8bef\u5e76\u4e0d\u4ee3\u8868\u300c\u8fd9\u4ee3\u7801\u4e0d\u80fd\u8fd0\u884c\u300d &#8230; \u800c\u662f\u4ee3\u7801\u663e\u5f97\u7cd9 &#8230; \u770b\u7740\u8ba9\u4eba\u96be\u53d7 &#8230;<\/p>\n<p>\u5b9e\u9645\u4e0a\u65f6\u81f3\u4eca\u65e5 php \u8fd8\u662f\u5141\u8bb8\u7528 self:: \u8c03\u7528\u975e\u9759\u6001\u65b9\u6cd5\u7684 &#8230; \u8fd9\u662f\u4e2a\u5386\u53f2\u9057\u7559\u95ee\u9898 &#8230; \u4e0d\u592a\u597d\u6539 &#8230;<\/p>\n<p>\u4f46\u4e0d\u62a5\u9519\u4e0d\u4ee3\u8868\u8fd9\u4e48\u5199\u5c31\u6ca1\u95ee\u9898 &#8230; \u4f60\u786e\u5b9e\u53ef\u4ee5\u8fd9\u4e48\u5199 &#8230; \u4f46\u4ece\u7ed3\u6784\u548c\u7f8e\u89c2\u7684\u89d2\u5ea6\u8bf4 &#8230; \u4f60\u90fd\u4e0d\u5e94\u8be5\u8fd9\u4e48\u5199 &#8230;<\/p>\n<p>\u8bf4\u53e5\u9898\u5916\u8bdd &#8230; \u6211\u4e00\u76f4\u89c9\u5f97\u300c\u7f16\u5199\u7a0b\u5e8f\u300d\u662f\u4e2a\u5f88 Creative \u7684\u4e8b\u60c5 &#8230; \u800c\u4e0d\u662f\u5e94\u4ed8\u8fc7\u53bb\u5b9e\u73b0\u4e86\u5c31\u5b8c\u4e86 &#8230;<\/p>\n<p>\u867d\u7136\u5f53\u4e0b\u884c\u4e1a\u91cc\u6df7\u65e5\u5b50\u7684\u7a0b\u5e8f\u5458\u5360\u5927\u591a\u6570 &#8230; \u4f46\u6211\u8fd8\u662f\u9009\u62e9\u7231\u60dc\u6211\u7684\u65f6\u95f4 &#8230; \u8ba4\u771f\u5bf9\u5f85\u6211\u7684\u6bcf\u4e00\u4ef6\u4f5c\u54c1 &#8230;                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5602113\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ChoateYao <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5f53\u4f60\u6709\u7236\u7c7b\uff0c\u91cc\u9762\u6709\u4e00\u4e2a\u4e24\u4e2a\u65b9\u6cd5 A \u548c B\uff0c\u5176\u4e2d A \u65b9\u6cd5\u4e2d\u8c03\u7528\u65b9\u6cd5 B\uff0cself::B()\u3002<\/p>\n<p>\u8fd9\u65f6\u5019\u5b50\u7c7b\uff0c\u91cd\u5199\u4e86\u65b9\u6cd5 B\uff0c\u5e76\u4f7f\u7528\u5b50\u7c7b\u521d\u59cb\u5316\uff0c\u5e76\u8c03\u7528\u65b9\u6cd5 A\uff0c\u5219\u5b50\u7c7b\u91cd\u5199\u7684\u65b9\u6cd5 B \u5e76\u4e0d\u4f1a\u751f\u6548\u3002<\/p>\n<p>\u7c7b\u4f3c\u4e8e final \u5173\u952e\u5b57\u58f0\u660e\uff0c\u5f88\u6076\u5fc3\uff0c\u4e00\u4e0d\u5c0f\u5fc3\u5c31\u6389\u5751\u4e86\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5602114\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : mengdodo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5c31\u4e0d\u8be5\u8fd9\u4e48\u5199\uff0c\u6574\u7684\u8ddf\u5947\u6280\u6deb\u5de7\u4e00\u6837\uff0c\u6211\u662f\u770b\u5230\u5c31\u4f1a\u9a82\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5602115\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : sorshion <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             php \u5c31\u5e94\u8be5\u5728\u5927\u7248\u672c\u4e2d\uff0c\u53bb\u9664\u4e00\u4e9b\u8fc7\u65f6\u7684\u8bed\u6cd5                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5602116\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : wfdaj <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u5728\u770b\u5fae\u6846\u67b6\uff0c\u90fd\u662f\u4ece github \u627e\u661f\u6570\u591a\uff0c\u6700\u8fd1\u6709\u66f4\u65b0\u7684\u770b\u3002<\/p>\n<p>\u8fd9\u4e2a mini3 \u4e00\u5171\u5c31 2 \u4e2a\u6587\u4ef6\uff0c140 \u884c\uff0c\u4ece\u6765\u6ca1\u4eba\u5c31\u8fd9\u884c\u63d0\u610f\u89c1\u5417\uff1f                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf7\u95ee PHP \u4e2d\u7684 self:: &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/419406"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=419406"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/419406\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=419406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=419406"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=419406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}