您的位置:首页 > 编程语言 > PHP开发

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

2016-07-11 14:39 645 查看
原因:

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/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  php smarty php5