$compileContent = preg_replace("/(\{cm:)include\s*(.+)(\})/i", "\$this->inc_file('$2')", $compileContent);现在 $this->inc_file('$2') 被当做字符串替换了如何用 $this->inc_file('$2') 返回的结果替换呢

解决方案 »

  1.   

    $compileContent = preg_replace("/(\{cm:)include\s*(.+)(\})/ie", "\$this->inc_file('$2')", $compileContent);
      

  2.   

    e
    如果设定了此修正符,preg_replace() 在替换字符串中对逆向引用作正常的替换,将其作为 PHP 代码求值,并用其结果来替换所搜索的字符串。
    只有 preg_replace() 使用此修正符,其它 PCRE 函数将忽略之。