{"id":23,"date":"2023-06-05T12:49:31","date_gmt":"2023-06-05T04:49:31","guid":{"rendered":"http:\/\/pro369.com\/php\/?p=23"},"modified":"2019-06-10T03:38:00","modified_gmt":"2019-06-10T03:38:00","slug":"%5bphp%5d-include-once-%e8%88%87-require-once%ef%bc%88%e5%8c%85%e5%90%ab%e5%85%b6%e5%ae%83%e7%9a%84%e6%aa%94%e6%a1%88%e9%80%b2%e4%be%86%ef%bc%89","status":"publish","type":"post","link":"https:\/\/por.tw\/php\/%5bphp%5d-include-once-%e8%88%87-require-once%ef%bc%88%e5%8c%85%e5%90%ab%e5%85%b6%e5%ae%83%e7%9a%84%e6%aa%94%e6%a1%88%e9%80%b2%e4%be%86%ef%bc%89\/","title":{"rendered":"[PHP] include_once \u8207 require_once\uff08\u5305\u542b\u5176\u5b83\u7684\u6a94\u6848\u9032\u4f86\uff09"},"content":{"rendered":"<p><strong><font size=\"3\"><span style=\"background-color: #ffff00\">[PHP] include_once \u8207 require_once\uff08\u5305\u542b\u5176\u5b83\u7684\u6a94\u6848\u9032\u4f86\uff09<\/span><\/p>\n<p> <font color=\"#800080\">include_once \u8207 require_once\u90fd\u662fPHP\u7684\u51fd\u5f0f\uff0c\u4e3b\u8981\u662f\u8981\u5305\u542b\u5176\u5b83\u7684\u6a94\u6848\u9032\u4f86\uff0c\u800c\u4e14\u842c\u4e00\u8a72\u6a94\u6848\u88ab\u5305\u542b\u904e\u4e86\uff0c\u5247\u4e0d\u6703\u91cd\u65b0\u518d\u5305\u542b\u4e00\u6b21\u3002<\/font><br \/> <font color=\"#008000\"><br \/> \u800c\u57fa\u65bcPHP\u4e0d\u53ef\u80fd\u958b\u767c\u540c\u4e00\u500b\u51fd\u5f0f\u7684\u60c5\u6cc1\u4e0b\uff0c\u53bb\u8a66\u4e86\u4e00\u4e0b\u4ed6\u7684\u4e0d\u540c\u4e4b\u8655\uff0c\u5728\u65bcinclude_once\u842c\u4e00\u9047\u5230\u932f\u8aa4\uff0c\u5247\u6703\u6301\u7e8c\u57f7\u884c\u3002<br \/> \u4f46require_once\u5247\u6703\u505c\u6b62\u57f7\u884c\uff0c\u4e26\u7522\u751fFatal Errors\u3002<\/font><\/p>\n<p> \u4ee5\u7a0b\u5f0f\u78bc\u8aaa\u660e\u5982\u4e0b\uff1a<\/p>\n<p> \u6a94\u540d\uff1atest.php<\/font><\/strong><\/p>\n<p> &lt;?php<br \/> &nbsp;require_once(&quot;a.php&quot;);<br \/> &nbsp;require_once(&quot;c.php&quot;);<br \/> &nbsp;echo dirname(__FILE__).&quot; in test.php &quot;;<br \/> ?&gt;<\/p>\n<p> \u6a94\u540d\uff1aa.php<\/p>\n<p> &lt;?php<br \/> &nbsp;echo dirname(__FILE__).&quot; in a.php&quot;.&quot;&lt;\/br&gt;&quot;;<br \/> &nbsp;require_once(&quot;b.php&quot;);<br \/> ?&gt;<\/p>\n<p> \u6a94\u540d\uff1ab.php<\/p>\n<p> &lt;?php<br \/> &nbsp;echo dirname(__FILE__).&quot; in b.php&quot;.&quot;&lt;\/br&gt;&quot;;<br \/> ?&gt;<\/p>\n<p> \u5247\u6703\u51fa\u73fe\u4e0b\u5217\u7d50\u679c\uff1a<br \/> C:AppServwwwPTS in a test.php<br \/> C:AppServwwwPTS in b test.php<\/p>\n<p> Warning: require_once(c.php) [function.require-once]: failed to open stream: No such file or directory in C:AppServwwwPTS est.php on line 3<\/p>\n<p> Fatal error: require_once() [function.require]: Failed opening required &#39;c.php&#39; (include_path=&#39;.;C:php5pear&#39;) in C:AppServwwwPTS est.php on line 3<br \/> \u4f46\u82e5\u662f\u6539\u6210include_once\uff0c\u5247\u6703\u8b8a\u6210<br \/> C:AppServwwwPTS in a test.php<br \/> C:AppServwwwPTS in b test.php<\/p>\n<p> Warning: require_once(c.php) [function.require-once]: failed to open stream: No such file or directory in C:AppServwwwPTS est.php on line 3<\/p>\n<p> Warning: include_once() [function.include]: Failed opening &#39;c.php&#39; for inclusion (include_path=&#39;.;C:php5pear&#39;) in C:AppServwwwPTS est.php on line 3<br \/> C:AppServwwwPTS in test.php<br \/> <font size=\"3\" color=\"#ff00ff\"><strong>\u7531\u6b64\u61c9\u8a72\u53ef\u4ee5\u5f88\u8f15\u6613\u5730\u770b\u51fa\u5169\u8005\u7684\u4e0d\u540c\u4e86\uff01<\/strong><\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>[PHP] include_once \u8207 require_once\uff08\u5305\u542b\u5176\u5b83\u7684\u6a94\u6848\u9032\u4f86\uff09 include_on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":383,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[22],"class_list":["post-23","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php-mysql-","tag-php"],"_links":{"self":[{"href":"https:\/\/por.tw\/php\/wp-json\/wp\/v2\/posts\/23"}],"collection":[{"href":"https:\/\/por.tw\/php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/por.tw\/php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/por.tw\/php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/por.tw\/php\/wp-json\/wp\/v2\/comments?post=23"}],"version-history":[{"count":0,"href":"https:\/\/por.tw\/php\/wp-json\/wp\/v2\/posts\/23\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/por.tw\/php\/wp-json\/wp\/v2\/media\/383"}],"wp:attachment":[{"href":"https:\/\/por.tw\/php\/wp-json\/wp\/v2\/media?parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/por.tw\/php\/wp-json\/wp\/v2\/categories?post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/por.tw\/php\/wp-json\/wp\/v2\/tags?post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}