使用Smarty模板2.x注入变量报错

来源:互联网 发布:红色鸡蛋花有毒吗 知乎 编辑:程序博客网 时间:2024/05/16 07:18

原因:

php5.5以后的preg_replace不再支持e模式修饰符,可以用preg_replace_callback函数替换。

解决办法:

找到文件 Smarty_Compiler.class.php 第270行:

/* replace special blocks by "{php}" */$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);

替换为:

// 解决:preg_replace(): The /e modifier is deprecated, use preg_replace_callback ins$source_content = preg_replace_callback($search, create_function ('$matches', "return '"                                . $this->_quote_replace($this->left_delimiter) . 'php'                                . "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'"                                . $this->_quote_replace($this->right_delimiter)                                . "';")                                , $source_content);

转载自:http://www.epooll.com/archives/791/

0 0
原创粉丝点击