{"id":30680,"date":"2024-11-25T12:11:12","date_gmt":"2024-11-25T04:11:12","guid":{"rendered":"https:\/\/fwq.ai\/blog\/30680\/"},"modified":"2024-11-25T12:11:12","modified_gmt":"2024-11-25T04:11:12","slug":"phpcms-v9%e5%a6%82%e4%bd%95%e5%85%b3%e9%97%ad%e7%bc%93%e5%ad%98","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/30680\/","title":{"rendered":"phpcms v9\u5982\u4f55\u5173\u95ed\u7f13\u5b58"},"content":{"rendered":"<p style=\"text-align: center\"><strong><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/020\/5e057015a25bc491.jpg\" class=\"aligncenter\" title=\"phpcms v9\u5982\u4f55\u5173\u95ed\u7f13\u5b58\u63d2\u56fe\" alt=\"phpcms v9\u5982\u4f55\u5173\u95ed\u7f13\u5b58\u63d2\u56fe\" \/><\/strong><\/p>\n<p><strong> v9\u5982\u4f55\u5173\u95ed\u7f13\u5b58<\/strong><\/p>\n<p><strong>\u53bb\u6389phpcms\u7684\u6a21\u677f\u7f13\u5b58<\/strong><\/p>\n<p>\u6700\u8fd1\u5728\u4f7f\u7528phpcms\u505a\u4e2a\u7b80\u5355\u7684\u4e1c\u897f,\u7531\u4e8e\u592a\u7b80\u5355\u4e86,\u6240\u4ee5\u76f4\u63a5\u5728ftp\u4e0a\u8c03\u8bd5\u4e86,\u4f46\u662f\u4e0a\u4f20\u4e86\u6a21\u677f\u6587\u4ef6,\u4f46\u662f\u524d\u53f0\u4e00\u76f4\u4e0d\u5237\u65b0,\u90fd\u5230\u8981\u7f13\u5b58\u76ee\u5f55\u4e0b\u53bb\u5220\u9664\u751f\u6210\u7684\u7f13\u5b58php,\u6765\u56de\u64cd\u4f5c\u51e0\u6b21\u611f\u89c9\u597d\u70e6,\u4f46\u662f\u5728\u7f51\u4e0a\u6ca1\u6709\u627e\u5230\u5408\u9002\u7684\u6587\u7ae0\u6765\u5173\u6389\u4ed6,\u6240\u4ee5\u5c31\u7b80\u5355\u7c97\u7206\u5730,\u5148\u5e72\u6389\u7f13\u5b58\u4e86<\/p>\n<p>global.func.php\u4e2d\u6709\u51fd\u6570\u540d\u4e3a<\/p>\n<pre>function&nbsp;template($module&nbsp;=&nbsp;'content',&nbsp;$template&nbsp;=&nbsp;'index',&nbsp;$style&nbsp;=&nbsp;'')\n&nbsp;&nbsp;if&nbsp;(file_exists(PC_PATH&nbsp;.&nbsp;'templates'&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$style&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$module&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$template&nbsp;.&nbsp;'.html'))\n&nbsp;&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!file_exists($compiledtplfile)&nbsp;||&nbsp;(@filemtime(PC_PATH&nbsp;.&nbsp;'templates'&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$style&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$module&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$template&nbsp;.&nbsp;'.html')&nbsp;&amp;gt;&nbsp;@filemtime($compiledtplfile)))\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$template_cache-&amp;gt;template_compile($module,&nbsp;$template,&nbsp;$style);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u628a\u91cc\u8fb9\u7684 if \u53bb\u6389\u5c31\u53ef\u4ee5\u4e86,\u8fd9\u6837\u591a\u4e48\u7b80\u5355\u7c97\u66b4\u554a,\u8fd9\u6837\u6bcf\u6b21\u90fd\u4ece\u7f16\u8bd1\u4e00\u4e0b,\u4e0d\u8fc7\u4e00\u4e2a\u7b80\u5355\u7684\u5c0f\u9879\u76ee\u8fd9\u4e2a\u4e5f\u4e0d\u7528\u592a\u5728\u610f\u4e86<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>&nbsp;&nbsp;if&nbsp;(file_exists(PC_PATH&nbsp;.&nbsp;'templates'&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$style&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$module&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$template&nbsp;.&nbsp;'.html'))\n&nbsp;&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;&nbsp;if&nbsp;(!file_exists($compiledtplfile)&nbsp;||&nbsp;(@filemtime(PC_PATH&nbsp;.&nbsp;'templates'&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$style&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$module&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$template&nbsp;.&nbsp;'.html')&nbsp;&amp;gt;&nbsp;@filemtime($compiledtplfile)))\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$template_cache-&amp;gt;template_compile($module,&nbsp;$template,&nbsp;$style);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;}\n&nbsp;&nbsp;}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>PHP\u4e2d\u6587\u7f51\uff0c\u5927\u91cf\u7684\u514d\u8d39\uff0c\u6b22\u8fce\u5728\u7ebf\u5b66\u4e60\uff01<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f v9\u5982\u4f55\u5173\u95ed\u7f13\u5b58\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>v9\u5982\u4f55\u5173\u95ed\u7f13\u5b58 \u53bb\u6389phpcms\u7684\u6a21\u677f\u7f13\u5b58 \u6700\u8fd1\u5728\u4f7f\u7528phpcms\u505a\u4e2a\u7b80\u5355\u7684\u4e1c\u897f,\u7531\u4e8e\u592a\u7b80\u5355\u4e86,\u6240\u4ee5\u76f4\u63a5\u5728ftp\u4e0a\u8c03\u8bd5\u4e86,\u4f46\u662f\u4e0a\u4f20\u4e86\u6a21\u677f\u6587\u4ef6,\u4f46\u662f\u524d\u53f0\u4e00\u76f4\u4e0d\u5237\u65b0,\u90fd\u5230\u8981\u7f13\u5b58\u76ee\u5f55\u4e0b\u53bb\u5220\u9664\u751f\u6210\u7684\u7f13\u5b58php,\u6765\u56de\u64cd\u4f5c\u51e0\u6b21\u611f\u89c9\u597d\u70e6,\u4f46\u662f\u5728\u7f51\u4e0a\u6ca1\u6709\u627e\u5230\u5408\u9002\u7684\u6587\u7ae0\u6765\u5173\u6389\u4ed6,\u6240\u4ee5\u5c31\u7b80\u5355\u7c97\u7206\u5730,\u5148\u5e72\u6389\u7f13\u5b58\u4e86 global.func.php\u4e2d\u6709\u51fd\u6570\u540d\u4e3a function&nbsp;template($module&nbsp;=&nbsp;&#8216;content&#8217;,&nbsp;$template&nbsp;=&nbsp;&#8216;index&#8217;,&nbsp;$style&nbsp;=&nbsp;&#8221;) &nbsp;&nbsp;if&nbsp;(file_exists(PC_PATH&nbsp;.&nbsp;&#8216;templates&#8217;&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$style&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$module&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$template&nbsp;.&nbsp;&#8216;.html&#8217;)) &nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!file_exists($compiledtplfile)&nbsp;||&nbsp;(@filemtime(PC_PATH&nbsp;.&nbsp;&#8216;templates&#8217;&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$style&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$module&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$template&nbsp;.&nbsp;&#8216;.html&#8217;)&nbsp;&amp;gt;&nbsp;@filemtime($compiledtplfile))) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$template_cache-&amp;gt;template_compile($module,&nbsp;$template,&nbsp;$style); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;} \u767b\u5f55\u540e\u590d\u5236 \u628a\u91cc\u8fb9\u7684 if \u53bb\u6389\u5c31\u53ef\u4ee5\u4e86,\u8fd9\u6837\u591a\u4e48\u7b80\u5355\u7c97\u66b4\u554a,\u8fd9\u6837\u6bcf\u6b21\u90fd\u4ece\u7f16\u8bd1\u4e00\u4e0b,\u4e0d\u8fc7\u4e00\u4e2a\u7b80\u5355\u7684\u5c0f\u9879\u76ee\u8fd9\u4e2a\u4e5f\u4e0d\u7528\u592a\u5728\u610f\u4e86 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b &nbsp;&nbsp;if&nbsp;(file_exists(PC_PATH&nbsp;.&nbsp;&#8216;templates&#8217;&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$style&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$module&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$template&nbsp;.&nbsp;&#8216;.html&#8217;)) &nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;&nbsp;if&nbsp;(!file_exists($compiledtplfile)&nbsp;||&nbsp;(@filemtime(PC_PATH&nbsp;.&nbsp;&#8216;templates&#8217;&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$style&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$module&nbsp;.&nbsp;DIRECTORY_SEPARATOR&nbsp;.&nbsp;$template&nbsp;.&nbsp;&#8216;.html&#8217;)&nbsp;&amp;gt;&nbsp;@filemtime($compiledtplfile))) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$template_cache-&amp;gt;template_compile($module,&nbsp;$template,&nbsp;$style); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;} &nbsp;&nbsp;} \u767b\u5f55\u540e\u590d\u5236 PHP\u4e2d\u6587\u7f51\uff0c\u5927\u91cf\u7684\u514d\u8d39\uff0c\u6b22\u8fce\u5728\u7ebf\u5b66\u4e60\uff01 \u4ee5\u4e0a\u5c31\u662f v9\u5982\u4f55\u5173\u95ed\u7f13\u5b58\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-30680","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30680","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=30680"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30680\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=30680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=30680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=30680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}