{"id":199434,"date":"2025-05-03T14:26:59","date_gmt":"2025-05-03T06:26:59","guid":{"rendered":"https:\/\/server.hk\/cnblog\/199434\/"},"modified":"2025-05-03T14:26:59","modified_gmt":"2025-05-03T06:26:59","slug":"%e8%ae%a9ecshop%e6%a8%a1%e6%9d%bf%e6%94%af%e6%8c%81php%e8%bf%90%e7%ae%97","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/199434\/","title":{"rendered":"\u8ba9ecshop\u6a21\u677f\u652f\u6301php\u8fd0\u7b97"},"content":{"rendered":"<p>\u8ba9 \u652f\u6301php\u8fd0\u7b97\u5728 cls_template.php \u5e95\u90e8\u52a0\u5165\u51fd\u6570\uff1a <\/p>\n<p> \/**<br \/>\n<br \/> * \u5904\u7406math\u4e2d\u7684\u516c\u5f0f. <\/p>\n<p> * *\/ <\/p>\n<p> function get_math_para($val){ <\/p>\n<p> $pa= $this-&gt;str_trim($val); <\/p>\n<p> foreach($pa AS $value) <\/p>\n<p> { <\/p>\n<p> if(strrpos($value, &#8216;=&#8217;)) <\/p>\n<p> { <\/p>\n<p> list($a, $b) = explode(&#8216;=&#8217;, str_replace(array(&#8216; &#8216;, &#8216;&#8221;&#8216;, &#8220;&#8216;&#8221;, &#8216;&#8221;&#8216;), &#8221;, $value)); <\/p>\n<p> if(strpos($b, &#8216;$&#8217;) &gt;= 0) <\/p>\n<p> { <\/p>\n<p> \/\/$b\u4e3a\u7c7b\u4f3c\u76841+2\uff0c$abc*123\u7b49 <\/p>\n<p> $pattern= &#8220;\/\\$[_a-zA-z]+[a-zA-Z0-9_]*\/&#8221;; <\/p>\n<p> preg_match($pattern, $b,$arr); <\/p>\n<p> if($arr) { <\/p>\n<p> foreach($arr as $match) { <\/p>\n<p> $v= $this-&gt;get_val(substr($match, 1)); <\/p>\n<p> $b= str_replace($match, $v, $b); <\/p>\n<p> } <\/p>\n<p> } <\/p>\n<p> } <\/p>\n<p> } <\/p>\n<p> } <\/p>\n<p> return$b; <\/p>\n<p> } <\/p>\n<p> [\/code] <\/p>\n<p> \u5728\u5927\u6982530\u884c\u5904\u52a0\u5165\uff1a<br \/>\n<br \/> [code lang=&#8221;php&#8221;]<br \/>\n<br \/> case &#8216;math&#8217;: <\/p>\n<p> $t= $this-&gt;get_math_para(substr($tag, 8)); <\/p>\n<p> return'&lt;?php echo &#8216;. $t. &#8216;; ?&gt;&#8217;; <\/p>\n<p> break; <\/p>\n<p> \u524d\u53f0\u6a21\u677f\u8c03\u7528\uff1a <\/p>\n<p> {math equation=&#8221;$key+1&#8243;} <\/p>\n<p> \u8fd9\u91cc\u6ce8\u610f\u7528\u53cc\u5f15\u53f7\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8ba9 \u652f\u6301php\u8fd0\u7b97\u5728 cls_t&#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-199434","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199434","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=199434"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199434\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=199434"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=199434"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=199434"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}