Ecshop How to Solve Deprecated:preg_replace () error

Source: Internet
Author: User

Today after the installation of Ecshop, running a variety of problems, including deprecated:preg_replace () such as the most error, the following post-solution:

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 an error similar to the following:

  Deprecated:preg_replace (): the/e modifier is Deprecated, use Preg_replace_callback instead in ...

Workaround:

  1. Deprecated:preg_replace (): the/e modifier is Deprecated, use Preg_replace_callback instead in \includes\cls_template. PHP on line 300  

Original content:

return Preg_replace ("/{([^\}\{]*)}/e", "\ $this->select (' \\1 ');", $source);

Modified content:

return Preg_replace_callback ("/{([^\}\{]*)}/", function ($r) {return $this->select ($r [1]);}, $SOURC e);

  2. Deprecated:preg_replace (): the/e modifier is Deprecated, use Preg_replace_callback instead in \includes\cls_template. PHP on line 491

Original content:

$out = "<?php ". ' $k = '. Preg_replace ("/(\ ' \\$[^,])/E", "Stripslashes (Trim (' \\1 ', ' \ '));", Var_export ($t, True)). "; ";

Modified content:

$out = "<?php ". ' $k = '. Preg_replace_callback ("/(\ ' \\$[^,])/", function ($match) {return stripslashes (Trim ($match [1], ' \ '));} , Var_export ($t, True)). "; "

  3. Deprecated:preg_replace (): the/e modifier is Deprecated, use Preg_replace_callback instead in \includes\cls_template. PHP on line 550

Original content:

$val = Preg_replace ("/\[([^\[\]]*) \]/eis", "'. '). Str_replace (' $ ', ' \$ ', ' \\1 ') ", $val);

Modified content:

$val = preg_replace_callback ('/\[([^\[\]]*) \]/is ',function ($matches) { Return '. '. Str_replace (' $ ', ' \$ ', $matches [1]); },$val);

  4 . Deprecated:preg_replace (): the/e modifier is Deprecated, use Preg_replace_callback instead in \includes\cls_template.ph P on line 1074

Original content:

$source = preg_replace ($pattern, $replacement, $source);

Modified content:

$source = Preg_replace_callback ($pattern, function ($matches) {return ' {include file= '. Strtol Ower ($matches [1]). '} ';},$source);

  5. Strict standards:only variables should be passed by reference in ... \upload\includes\lib_main.php on line 1329

Original content:

$ext = End (Explode ('. ', $tmp));

Modified content:

      $extsub = Explode ('. ', $tmp);

      $tmp = End ($extsub);

$tmp = basename ($tmp, ". $ext");

Finally, the error is modified and uploaded to the server. Then go backstage, empty the cache, and refresh the page.

Ecshop How to Solve Deprecated:preg_replace () error

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.