使用Smarty模板2.x注入变量报错
原因:
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("
", substr_count("\0", "
")) .""
. $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("
", substr_count("$matches[1]", "
")) .""
. $this->_quote_replace($this->right_delimiter)
. "";")
, $source_content);
转载自:http://www.epooll.com/archives/791/
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。