An error like this:
Deprecated: Preg_replace (): the/e modifier is Deprecated, use Preg_replace_callback instead inD:\wyh\ ecshop\includes\cls_template.php on line
1. Cause of Error:
The modifier used in the Preg_replace () function,/E, has been deprecated in php5.5.x.
If your PHP version happens to be php5.5.x, your ecshop will surely report something like this.
2, the solution:
One, will cls_template.php of 300 lines
returnpreg_replace("/{([^\}\{\n]*)}/e", "\$this->select(‘\\1‘);", $source); |
Into:
returnpreg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return$this->select($r[1]); }, $source); |
Two, will cls_template.php 493 lines
$out= "<?php \n" . ‘$k = ‘ . preg_replace("/(\‘\\$[^,]+)/e","stripslashes(trim(‘\\1‘,‘\‘‘));", var_export($t, true)) . ";\n"; |
Into:
$out= <?php \n" . ‘$k = ‘ . preg_replace_callback("/(\‘\\$[^,]+)/" , function($r) {return stripslashes(trim($r[1],‘\‘‘));}, var_export($t, true)) . ";\n"; |
Three, will cls_template.php of 552 lines
$val= preg_replace("/\[([^\[\]]*)\]/eis", "‘.‘.str_replace(‘$‘,‘\$‘,‘\\1‘)",$val); |
Into:
$val= preg_replace_callback("/\[([^\[\]]*)\]/", function($r) {return‘.‘.str_replace(‘$‘,‘$‘,$r[1]);}, $val); |
Four, will cls_template.php of 1069 lines
$pattern= ‘/<!--\s#BeginLibraryItem\s\"\/(.*?)\"\s-->.*?<!--\s#EndLibraryItem\s-->/se‘; |
$replacement= "‘{include file=‘.strtolower(‘\\1‘). ‘}‘"; |
$source= preg_replace($pattern, $replacement, $source); |
Into:
$pattern = < /code> '/<!--\s#beginlibraryitem\s\ "\ \ (. *?) \ "\s-->.*?<!--\s#endlibraryitem\s-->/s ' |
$source= preg_replace_callback($pattern, function($r){return‘{include file=‘.strtolower($r[1]). ‘}‘;}, $source); |
Ecshop php5.4 above version error preg_replace replaced with Preg_replace_callback