{"id":60543,"date":"2025-04-24T11:51:07","date_gmt":"2025-04-24T03:51:07","guid":{"rendered":"https:\/\/fwq.ai\/blog\/60543\/"},"modified":"2025-04-24T11:51:07","modified_gmt":"2025-04-24T03:51:07","slug":"ecshop%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3deprecated-preg_replace%e6%8a%a5%e9%94%99-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/60543\/","title":{"rendered":"ecshop\u5982\u4f55\u89e3\u51b3DEPRECATED: PREG_REPLACE()\u62a5\u9519"},"content":{"rendered":"<p>ecshop\u51fa\u73b0\u7c7b\u4f3c\u8fd9\u6837\u7684\u62a5\u9519\uff1a   &nbsp;   Deprecated: preg_replace(): The \/e modifier is deprecated, use preg_replace_callback instead in D:\\wyh\\ecshop\\includes\\cls_template.php on line 300   &nbsp;   1\u3001\u9519\u8bef\u539f\u56e0\uff1a   preg_replace() \u51fd\u6570\u4e2d\u7528\u5230\u7684\u4fee\u9970\u7b26 \/e \u5728 PHP5.5.x \u4e2d\u5df2\u7ecf\u88ab\u5f03\u7528\u4e86\u3002   \u5982\u679c\u4f60\u7684PHP\u7248\u672c\u6070\u597d\u662fPHP5.5.X\uff0c\u90a3\u4f60\u7684ECSHOP\u80af\u5b9a\u5c31\u4f1a\u62a5\u7c7b\u4f3c\u8fd9\u6837\u7684\u9519\u8bef\u3002   &nbsp;   2\u3001\u89e3\u51b3\u529e\u6cd5\uff1a   &nbsp;   \u4e00\u3001\u5c06 cls_template.php\u7684300\u884c   &nbsp;   &nbsp;   return preg_replace(&#8220;\/{([^\\}\\{\\n]*)}\/e&#8221;, &#8220;\\$this-&gt;select(&#8216;\\\\1&#8217;);&#8221;, $source);   \u6362\u6210\uff1a   &nbsp;   &nbsp;   return preg_replace_callback(&#8220;\/{([^\\}\\{\\n]*)}\/&#8221;, function($r) { return $this-&gt;select($r[1]); }, $source);   \u4e8c\u3001\u5c06cls_template.php\u7684493\u884c   &nbsp;   &nbsp;   $out = &#8220;&lt;?php \\n&#8221; . &#8216;$k = &#8216; . preg_replace(&#8220;\/(\\&#8217;\\\\$[^,]+)\/e&#8221; , &#8220;stripslashes(trim(&#8216;\\\\1&#8217;,&#8217;\\&#8221;));&#8221;, var_export($t, true)) . &#8220;;\\n&#8221;;   \u6362\u6210\uff1a   &nbsp;   &nbsp;   $out = &lt;?php \\n&#8221; . &#8216;$k = &#8216; . preg_replace_callback(&#8220;\/(\\&#8217;\\\\$[^,]+)\/&#8221; , function($r) {return stripslashes(trim($r[1],&#8217;\\&#8221;));}, var_export($t, true)) . &#8220;;\\n&#8221;;   \u4e09\u3001\u5c06cls_template.php\u7684552\u884c   &nbsp;   &nbsp;   $val = preg_replace(&#8220;\/\\[([^\\[\\]]*)\\]\/eis&#8221;, &#8220;&#8216;.&#8217;.str_replace(&#8216;$&#8217;,&#8217;\\$&#8217;,&#8217;\\\\1&#8242;)&#8221;, $val);   \u6362\u6210\uff1a   &nbsp;   &nbsp;   $val = preg_replace_callback(&#8220;\/\\[([^\\[\\]]*)\\]\/&#8221;, function($r) {return &#8216;.&#8217;.str_replace(&#8216;$&#8217;,&#8217;$&#8217;,$r[1]);}, $val);   \u56db\u3001\u5c06cls_template.php\u76841069\u884c   &nbsp;   &nbsp;   $pattern = &#8216;\/&lt;!&#8211;\\s#BeginLibraryItem\\s\\&#8221;\\\/(.*?)\\&#8221;\\s&#8211;&gt;.*?&lt;!&#8211;\\s#EndLibraryItem\\s&#8211;&gt;\/se&#8217;;   $replacement = &#8220;&#8216;{include file=&#8217;.strtolower(&#8216;\\\\1&#8217;). &#8216;}'&#8221;;   $source = preg_replace($pattern, $replacement, $source);   \u6362\u6210\uff1a   &nbsp;   &nbsp;   $pattern = &#8216;\/&lt;!&#8211;\\s#BeginLibraryItem\\s\\&#8221;\\\/(.*?)\\&#8221;\\s&#8211;&gt;.*?&lt;!&#8211;\\s#EndLibraryItem\\s&#8211;&gt;\/s&#8217;;   $source = preg_replace_callback($pattern, function($r){return &#8216;{include file=&#8217;.strtolower($r[1]). &#8216;}&#8217;;}, $source);   &nbsp;  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>ecshop\u51fa\u73b0\u7c7b\u4f3c\u8fd9\u6837\u7684\u62a5\u9519\uff1a &nbsp; Deprecated: preg_replace(): The \/e modifier is deprecated, use preg_replace_callback instead in D:\\wyh\\ecshop\\includes\\cls_template.php on line 300 &nbsp; 1\u3001\u9519\u8bef\u539f\u56e0\uff1a preg_replace() \u51fd\u6570\u4e2d\u7528\u5230\u7684\u4fee\u9970\u7b26 \/e \u5728 PHP5.5.x \u4e2d\u5df2\u7ecf\u88ab\u5f03\u7528\u4e86\u3002 \u5982\u679c\u4f60\u7684PHP\u7248\u672c\u6070\u597d\u662fPHP5.5.X\uff0c\u90a3\u4f60\u7684ECSHOP\u80af\u5b9a\u5c31\u4f1a\u62a5\u7c7b\u4f3c\u8fd9\u6837\u7684\u9519\u8bef\u3002 &nbsp; 2\u3001\u89e3\u51b3\u529e\u6cd5\uff1a &nbsp; \u4e00\u3001\u5c06 cls_template.php\u7684300\u884c &nbsp; &nbsp; return preg_replace(&#8220;\/{([^\\}\\{\\n]*)}\/e&#8221;, &#8220;\\$this-&gt;select(&#8216;\\\\1&#8217;);&#8221;, $source); \u6362\u6210\uff1a &nbsp; &nbsp; return preg_replace_callback(&#8220;\/{([^\\}\\{\\n]*)}\/&#8221;, function($r) { return $this-&gt;select($r[1]); }, $source); \u4e8c\u3001\u5c06cls_template.php\u7684493\u884c &nbsp; &nbsp; $out = &#8220;&lt;?php \\n&#8221; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-60543","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/60543","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=60543"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/60543\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=60543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=60543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=60543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}