正则替换有关问题
程序员文章站
2022-05-17 17:26:20
...
正则替换问题
$compileContent = preg_replace("/(\{cm:)include\s*(.+)(\})/i", "\$this->inc_file('$2')", $compileContent);
现在 $this->inc_file('$2') 被当做字符串替换了
如何用 $this->inc_file('$2') 返回的结果替换呢
------解决方案--------------------
$compileContent = preg_replace("/(\{cm:)include\s*(.+)(\})/ie", "\$this->inc_file('$2')", $compileContent);
$compileContent = preg_replace("/(\{cm:)include\s*(.+)(\})/i", "\$this->inc_file('$2')", $compileContent);
现在 $this->inc_file('$2') 被当做字符串替换了
如何用 $this->inc_file('$2') 返回的结果替换呢
------解决方案--------------------
$compileContent = preg_replace("/(\{cm:)include\s*(.+)(\})/ie", "\$this->inc_file('$2')", $compileContent);
相关文章
相关视频