結合設計經驗與營銷實踐,提供有價值的互聯網資訊
發布日期:2018-03-13瀏覽次數:1293 來源:福州網站建設
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in D:wyhecshopincludescls_template.php on line 300
1、錯誤原因:
preg_replace() 函數中用到的修飾符 /e 在 PHP5.5.x 中已經被棄用了。
如果你的PHP版本恰好是PHP5.5.X,那你的ECSHOP肯定就會報類似這樣的錯誤。
2、解決辦法:
一、將 cls_template.php的300行
return preg_replace("/{([^}{
]*)}/e", "$this->select('\1');", $source); |
換成:
return preg_replace_callback("/{([^}{
]*)}/", function($r) { return $this->select($r[1]); }, $source); |
二、將cls_template.php的493行
$out = "<?php
" . '$k = ' . preg_replace("/('\$[^,]+)/e" , "stripslashes(trim('\1','''));", var_export($t, true)) . ";
"; |
換成:
$out = <?php
" . '$k = ' . preg_replace_callback("/('\$[^,]+)/" , function($r) {return stripslashes(trim($r[1],'''));}, var_export($t, true)) . ";
"; |
三、將cls_template.php的552行
$val = preg_replace("/[([^[]]*)]/eis", "'.'.str_replace('$','$','\1')", $val); |
換成:
$val = preg_replace_callback("/[([^[]]*)]/", function($r) {return '.'.str_replace('$','$',$r[1]);}, $val); |
四、將cls_template.php的1069行
$pattern = '/<!--s#BeginLibraryItems"/(.*?)"s-->.*?<!--s#EndLibraryItems-->/se'; |
$replacement = "'{include file='.strtolower('\1'). '}'"; |
$source = preg_replace($pattern, $replacement, $source); |
換成:
$pattern = '/<!--s#BeginLibraryItems"/(.*?)"s-->.*?<!--s#EndLibraryItems-->/s'; |
$source = preg_replace_callback($pattern, function($r){return '{include file='.strtolower($r[1]). '}';}, $source);
以上是由福州網站建設的小編為你分享了"php5.5以上ECSHOP如何解決Deprecated: preg_replace()報錯"文章,如果你在這方面有什么問題,隨時聯系我們