Ecshop php5.4 above version error preg_replace replaced with Preg_replace_callback

Source: Internet
Author: User

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($patternfunction($r){return‘{include file=‘.strtolower($r[1]). ‘}‘;}, $source);

Ecshop php5.4 above version error preg_replace replaced with Preg_replace_callback

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.