PHP升级之preg_replace转preg_replace_

2019-05-15  本文已影响0人  飞雪连天_4378

1,原来://变量标签

/* $this->content = preg_replace ("/\{$stag:([a-zA-Z_0-9\[\]\'\"\$\x7f-\xff\+\-\*\/]+)\}/es",

"\$this->addquote('<?php echo \\1; ?>')",$this->content);*/

现在:$this->content = preg_replace_callback(

            "/\{$stag:([a-zA-Z_0-9\[\]\'\"\$\x7f-\xff\+\-\*\/]+)\}/",

            function ($matches){  return $this->addquote('<?php echo '.$matches[1].'; ?>');},$this->content);

2,原来:/* $this->content = preg_replace ("/\{$stag:(\\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)([\$a-zA-Z_0-9\[\]\'\"\$\x7f-\xff]+)\}/es",

"\$this->addquote('<?php echo \\1\\2; ?>')",$this->content);*/

现在:$this->content = preg_replace_callback(

            "/\{$stag:(\\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)\s*([\+\-\*\/])\s*(\\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)\}/",

            function ($matches){  return $this->addquote('<?php echo '.$matches[1].$matches[2].'; ?>');},$this->content);

3, //保留标签

原来:/* $this->content = preg_replace ( "/\{$stag:(\w+)\s+([^}]+)\}/ie", "self::pc_tag_html('$1','$2', '$0')", $this->content);*/

现在:$this->content = preg_replace_callback(

            "/\{$stag:(\w+)\s+([^}]+)\}/",

            function ($matches){  return self::pc_tag_html($matches[1],$matches[2], $matches[0]);},$this->content);

//模块调用标签

4,原来:/* $this->content = preg_replace ( "/\{$stag:m=(\w+) mod=[\"|\'](\w+)[\"|\']([^}]+)\}/ie", "self::pc_module_tag('$1','$2', '$3')", $this->content); */

现在:$this->content = preg_replace_callback(

            "/\{$stag:m=(\w+) mod=[\"|\'](\w+)[\"|\']([^}]+)\}/",

            function ($matches){  return self::pc_module_tag($matches[1],$matches[2], $matches[3]);},$this->content);

上一篇 下一篇

猜你喜欢

热点阅读