MENU service case
 Website construction website design Beijing website construction high-end website production company Shangpin China
We create by embracing change
360 ° brand value__
simplified Chinese character
Simplified Chinese English

Shangpin China Joins Hands with Beisheng Internet to Create a New Chapter in Website Construction

Type: Shangpin Dynamic Learn more

How smart is perfectly compatible with php5.5 and preg_replace_callback How to replace preg_replace

Source: Shangpin China | Type: website encyclopedia | Time: 2015-05-29
Now the PHP 5.5 version comes out, and I installed some changes. The smart we used is incompatibility, and the following error occurs once running:
 preg_replace():
 

This means that the/e parameter in preg_replace_callback is replaced by preg_replace_callback, which may be cancelled in PHP 5.5 for security reasons, but the preg_replace_callback function is not easy to use, I removed the preg_replace (e in $search.'e ') in the 270th line of the Smarty_Compiler.class.php file. It was really good, but the problem came up again. The chance of this problem coming up was not many. It was just that the php tag code {php} {/php} could not be written in the smart template.

There is no way to replace the preg_replace() with the preg_replace_callback() function. The specific replacement method is as follows:

Add a method to the Smarty_Compiler class:

function callback_source($matches){
return "".$ this->_quote_replace($this->left_delimiter). "php".str_repeat("n",substr_count("","n")). "".$ this->_quote_replace($this->right_delimiter). "";
}

Then find around line 270:
$source_content = preg_replace($search.'e', "'"
. $this->_quote_replace($this->left_delimiter) . ' php'
. "' . str_repeat("n", substr_count('\0', "n")) .'"
. $this->_quote_replace($this->right_delimiter)
. "'"
, $source_content);

Replace with:

$source_content = preg_replace_callback($search,
array("self","callback_source")
, $source_content);

That's fine, so it's perfectly compatible with php5.5.

This article was published on Shangpin China Website production company
Source Statement: This article is original or edited by Shangpin China's editors. If it needs to be reproduced, please indicate that it is from Shangpin China. The above contents (including pictures and words) are from the Internet. If there is any infringement, please contact us in time (010-60259772).
TAG label:

What if your website can increase the number of conversions and improve customer satisfaction?

Make an appointment with a professional consultant to communicate!

* Shangpin professional consultant will contact you as soon as possible

Disclaimer

Thank you very much for visiting our website. Please read all the terms of this statement carefully before you use this website.

1. Part of the content of this site comes from the network, and the copyright of some articles and pictures involved belongs to the original author. The reprint of this site is for everyone to learn and exchange, and should not be used for any commercial activities.

2. This website does not assume any form of loss or injury caused by users to themselves and others due to the use of these resources.

3. For issues not covered in this statement, please refer to relevant national laws and regulations. In case of conflict between this statement and national laws and regulations, the national laws and regulations shall prevail.

4. If it infringes your legitimate rights and interests, please contact us in time, and we will delete the relevant content at the first time!

Contact: 010-60259772
E-mail: [email protected]

Communicate with professional consultants now!

  • National Service Hotline

    400-700-4979

  • Beijing Service Hotline

    010-60259772

Please be assured to fill in the information protection
Online consultation

Disclaimer

Thank you very much for visiting our website. Please read all the terms of this statement carefully before you use this website.

1. Part of the content of this site comes from the network, and the copyright of some articles and pictures involved belongs to the original author. The reprint of this site is for everyone to learn and exchange, and should not be used for any commercial activities.

2. This website does not assume any form of loss or injury caused by users to themselves and others due to the use of these resources.

3. For issues not covered in this statement, please refer to relevant national laws and regulations. In case of conflict between this statement and national laws and regulations, the national laws and regulations shall prevail.

4. If it infringes your legitimate rights and interests, please contact us in time, and we will delete the relevant content at the first time!

Contact: 010-60259772
E-mail: [email protected]