官網提示是這樣的,對/e修飾符的支持已刪除。請改用preg_replace_callback()
緣由是/e 修正符使 preg_replace() 將 replacement 參數看成 PHP 代碼(在適當的逆向引用替換完以後),會被一句話後門使用php
看看smarty中是也是這樣用的,也是存在問題
$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);
能夠把smarty模板修改爲這個
$source_content = preg_replace_callback($search, function ($matches){
$str="";
$str.=$this->_quote_replace($this->left_delimiter) . 'php';
$str.=str_repeat("\\n\\", substr_count($matches[1], "\\n\\"));
$str.=$this->_quote_replace($this->right_delimiter);
return $str;
}, $source_content);this