入门客AI创业平台(我带你入门,你带我飞行)
博文笔记

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

创建时间:2016-07-11 投稿人: 浏览次数:421

原因:

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/

声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
  • 上一篇:没有了
  • 下一篇:没有了
未上传头像