PHPCMS模板preg_replace函数报错
修改文件:/phpcms/libs/classes/template_cache.class.php
把
$str = preg_replace("/\{(\\$[a-zA-Z0-9_\[\]\'\"\$\x7f-\xff]+)\}/es", "\$this->addquote('<?php echo \\1;?>')",$str);
替换成
$str = preg_replace_callback("/\{(\\$[a-zA-Z0-9_\[\]\'\"\$\x7f-\xff]+)\}/s", function($matches){ return $this->addquote('<?php echo '.$matches[1].';?>'); },$str);
把
$str = preg_replace("/\{pc:(\w+)\s+([^}]+)\}/ie", "self::pc_tag('$1','$2', '$0')", $str);
替换成
$str = preg_replace_callback("/\{pc:(\w+)\s+([^}]+)\}/i", function($matches){ return self::pc_tag($matches[1],$matches[2], $matches[0]); }, $str);
把
$str = preg_replace("/\{\/pc\}/ie", "self::end_pc_tag()", $str);
替换成
str = preg_replace_callback("/\{pc:(\w+)\s+([^}]+)\}/i", function($matches){ return self::pc_tag($matches[1],$matches[2], $matches[0]); }, $str);
修改文件:/phpcms/modules/content/fields/editor/output.inc.php
把
$search = "/(alt\s*=\s*|title\s*=\s*)[\"|\'](.+?)[\"|\']/ise";
替换成
$search = "/(alt\s*=\s*|title\s*=\s*)[\"|\'](.+?)[\"|\']/is";
把
$txt = preg_replace($search, $replace, $txt);
替换成
$txt = preg_replace_callback( $search, function ($matches) { return $this->_base64_encode($matches[0],$matches[1]); }, $txt);
把
$txt = preg_replace($search, $replace1, $txt);
替换成
$txt = preg_replace_callback( $search, function ($matches) { return $this->_base64_encode($matches[0],$matches[1]); }, $txt);
Dcr163的博客
http://dcr163.cn/186.html(转载时请注明本文出处及文章链接)