{"id":199574,"date":"2025-05-03T09:59:26","date_gmt":"2025-05-03T01:59:26","guid":{"rendered":"https:\/\/server.hk\/cnblog\/199574\/"},"modified":"2025-05-03T09:59:26","modified_gmt":"2025-05-03T01:59:26","slug":"ecshop%e6%a8%a1%e6%9d%bf%e4%b8%8d%e6%94%af%e6%8c%81%e5%bc%95%e5%85%a5php%e8%af%ad%e5%8f%a5%e7%9a%84%e8%a7%a3%e5%86%b3%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/199574\/","title":{"rendered":"ecshop\u6a21\u677f\u4e0d\u652f\u6301\u5f15\u5165PHP\u8bed\u53e5\u7684\u89e3\u51b3\u65b9\u6cd5"},"content":{"rendered":"<p>ECSHOP\u4e8c\u6b21\u5f00\u53d1\u4e2d\u6709\u65f6\u4e3a\u4e86\u5f00\u53d1\u7684\u65b9\u4fbf\uff0c\u4f1a\u628a\u4e00\u4e9bPHP\u7684\u7a0b\u5e8f\u76f4\u63a5\u52a0\u5165\u5230\u6a21\u677f\u6587\u4ef6\u4e2d\u53bb\uff0c\u4ee5\u4fbf\u4e8e\u5feb\u6377\u8c03\u8bd5\uff0c\u5b98\u65b9\u8003\u8651\u5230\u5b89\u5168\u95ee\u9898\uff0c\u7279\u522b\u5c06\u6a21\u677f\u4e2d\u5f15\u5165\u7684PHP\u7a0b\u5e8f\u8fdb\u5165\u8fc7\u6ee4\u5904\u7406\uff0c\u5bfc\u81f4PHP\u8fd9\u79cd\u5feb\u6377\u8c03\u8bd5\u65e0\u6cd5\u7ee7\u7eed\u5f80\u4e0b\u8fdb\u884c\uff0c\u90a3\u4e48\u5982\u4f55\u6765\u5904\u7406\u8fd9\u4e2a\u95ee\u9898\u5462\uff0c\u8bf7\u7ee7\u7eed\u5f80\u4e0b\u8bfb\u3002   \u9996\u9875\u627e\u5230includes\u76ee\u5f55\u4e0b\u7684cls_template.php\u7a0b\u5e8f\u6587\u4ef6\uff0c\u5e76\u6253\u5f00\uff0c\u67e5\u627e\u7ea6293\u884cfunction fetch_str($source)\u51fd\u6570\u65b9\u6cd5\uff0c\u627e\u5230\u5982\u4e0b\u4ee3\u7801\uff1a   &nbsp;   $source = str_replace($sp_match[1][$curr_sp],&#8217;%%%SMARTYSP&#8217;.$curr_sp.&#8217;%%%&#8217;,$source); &nbsp;   \u66ff\u6362\u4e3a\u4e0b\u9762\u4e00\u6bb5\u4ee3\u7801\uff0c\u4e0d\u9700\u8981\u66ff\u6362\u5904\u7406\u53ef\u76f4\u63a5\u5220\u9664\u6216\u5728\u524d\u9762\u52a0\u4e0a\/\/\u6ce8\u91ca\u6389\u3002   &nbsp;   \/\/$source = str_replace($sp_match[1][$curr_sp],&#8217;%%%SMARTYSP&#8217;.$curr_sp.&#8217;%%%&#8217;,$source); &nbsp;   \u8fd9\u91cc\u8fd8\u53ef\u4ee5\u4f7f\u7528\u53e6\u5916\u4e00\u79cd\u65b9\u6cd5\uff0c\u8003\u8651\u5230\u5b89\u5168\u56e0\u7d20\uff0c\u4e0d\u6781\u529b\u63a8\u8350\u4f7f\u7528\uff0c\u627e\u5230\u4e0b\u9762\u4e00\u6bb5\u4ee3\u7801\uff1a   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; if(preg_match_all(&#8216;~(&lt;\\?(?:\\w+|=)?|\\?&gt;|language\\s*=\\s*[\\&#8221;\\&#8217;]?php[\\&#8221;\\&#8217;]?)~is&#8217;, $source, $sp_match)) &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $sp_match[1] = array_unique($sp_match[1]); &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp &lt; $for_max2; $curr_sp++) &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $source = str_replace($sp_match[1][$curr_sp],&#8217;%%%SMARTYSP&#8217;.$curr_sp.&#8217;%%%&#8217;,$source); &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp &lt; $for_max2; $curr_sp++) &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$source= str_replace(&#8216;%%%SMARTYSP&#8217;.$curr_sp.&#8217;%%%&#8217;, &#8216;&lt;?php echo \\&#8221;.str_replace(&#8220;&#8216;&#8221;, &#8220;\\'&#8221;, $sp_match[1]&nbsp;   &nbsp;   [$curr_sp]).&#8217;\\&#8217;; ?&gt;&#8217;.&#8221;\\n&#8221;, $source); &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} &nbsp;   \u5220\u9664\u5373\u53ef\uff0c\u6700\u540e\u540e\u53f0\u6e05\u9664\u7f13\u5b58\uff0c\u4f7f\u7528\u6700\u7b80\u5355\u4e00\u7684\u53e5\u4ee3\u7801\u52a0\u5165\u5230\u6a21\u677f\u9875\u5185\u6765\u6d4b\u8bd5\u4e0b\u8f93\u51fa\uff1a   \u590d\u5236\u5185\u5bb9\u5230\u526a\u8d34\u677f\u6298\u53e0XML\/HTML \u4ee3\u7801   &lt;?php &nbsp;   echo &#8220;test&#8230;.&#8221; &nbsp;   ?&gt; &nbsp;  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>ECSHOP\u4e8c\u6b21\u5f00\u53d1\u4e2d\u6709\u65f6\u4e3a\u4e86\u5f00&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-199574","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199574","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=199574"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199574\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=199574"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=199574"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=199574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}