Preg_replace-ecshop error in php5.6.

Source: Internet
Author: User
Ecshop error in php5.6. Under 5.3, it is normal. It should be a function change in PHP later versions. Error message: Deprecated: preg_replace (): Theemodifierisdeprecated, usepreg_replace_callbackinsteadinhomewwwrootwww.ufe... ecshop error in php5.6. Under 5.3, it is normal. It should be a function change in PHP later versions.

Error message:

Deprecated: preg_replace (): The/e modifier is deprecated, use preg_replace_callback instead in/home/wwwroot/www.ufeelwine.com/#des/cls_template.php on line 1061

Deprecated: preg_replace (): The/e modifier is deprecated, use preg_replace_callback instead in/home/wwwroot/www.ufeelwine.com/#des/cls_template.php on line 483

Specific webpage address:
Http://www.ufeelwine.com/supplier.php? SuppId = 7

Row 3:

                    $out = "
  _echash . $k[\'name\'] . \'|\' . serialize($k) . $this->_echash;' . "\n?>";

Row 3:

            $pattern     = '/
  .*?
  /se';            $replacement = "'{include file='.strtolower('\\1'). '}'";            $source      = preg_replace($pattern, $replacement, $source);

How should I rewrite it?

Reply content:

Ecshop error in php5.6. Under 5.3, it is normal. It should be a function change in PHP later versions.

Error message:

Deprecated: preg_replace (): The/e modifier is deprecated, use preg_replace_callback instead in/home/wwwroot/www.ufeelwine.com/#des/cls_template.php on line 1061

Deprecated: preg_replace (): The/e modifier is deprecated, use preg_replace_callback instead in/home/wwwroot/www.ufeelwine.com/#des/cls_template.php on line 483

Specific webpage address:
Http://www.ufeelwine.com/supplier.php? SuppId = 7

Row 3:

                    $out = "
  _echash . $k[\'name\'] . \'|\' . serialize($k) . $this->_echash;' . "\n?>";

Row 3:

            $pattern     = '/
  .*?
  /se';            $replacement = "'{include file='.strtolower('\\1'). '}'";            $source      = preg_replace($pattern, $replacement, $source);

How should I rewrite it?

// -- Original

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

// -- Modify

return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->select($r[1]); }, $source);

// -- Original

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

// -- Modify

$val = preg_replace_callback("/\[([^\[\]]*)\]/is", function($r) { return '.'.$r[1]; }, $val);

// -- Original

$out = "
  

// -- Modify

$out = " 

// --- Original

$pattern = '/ .*? /se';$replacement = "'{include file='.strtolower('\\1'). '}'";$source = preg_replace($pattern, $replacement, $source);

// --- Modify

$pattern = '/ .*? /s';$replacement = function ($r) { return '{include file='.strtolower($r[1]). '}'; };$source = preg_replace_callback($pattern, $replacement, $source);

Try it. there is no environment to test. you can modify it according to the prompt.

Row 3: changed

$out = "
    

Row 3: changed

//$pattern = '/ .*? /se';//$replacement = "'{include file='.strtolower('\\1'). '}'";$source = preg_replace('/ .*? /se', function($r) { return '{include file='.strtolower('\\1'). '}';}, $source);

The prompt is clear.
Replace preg_replace with preg_replace_callback
Let's see the usage of preg_replace_callback.

/* 1. remove e parameter 2. replace \ 1 with the elements corresponding to the callback array * // 483 rows $ out ="
     
Related Article

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.