如今PHP5.5版本号出来,我装了一下修改还真很大,我们用的smarty竟然兼容问题了,一运作出現下列不正确:
意思是怎么用preg_replace_callback来替代preg_replace里的/e主要参数,很有可能是由于安全系数的考虑到,在php5.5中把这个主要参数取消了,可是这一preg_replace_callback涵数用起來不随手,我也把哪个Smarty_Compiler.class.php文件里的第270行里的preg_replace($search.'e'里的e除掉了,果真好啦,但是难题又出来,这个问题出去的概率很少,便是没法在smarty模版里载入php标识编码:{php}{/php}。
没法還是要把这个preg_replace()用preg_replace_callback()涵数来更换,实际更换方式 以下:
在Smarty_Compiler这一类里添加一个方式 :
function callback_source($matches){
return "".$this->_quote_replace($this->left_delimiter)."php".str_repeat("n",substr_count("","n"))."".$this->_quote_replace($this->right_delimiter)."";
}
随后在第270行上下寻找:
$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);
换成:
$source_content = preg_replace_callback($search,
array("self","callback_source")
, $source_content);
就可以,那样就可以极致适配php5.5了。
文中公布于
酷站科技 网站制作企业