代码之家  ›  专栏  ›  技术社区  ›  Wouter Dorgelo voy

Zend有没有像Smarty中的{strip}这样的东西?

  •  0
  • Wouter Dorgelo voy  · 技术社区  · 14 年前

    Smarty有一个{strip}函数:

    {strip}
    <table border='0'>
     <tr>
      <td>
       Hello world
      </td>
     </tr>
    </table>
    {/strip}
    

    哪些输出:

    <table border='0'><tr><td>Hello world</td></tr></table>
    

    我还想在Zend中这样做(以减少每次请求发送的比特数),而不安装Smarty。

    但是,我不想在每个Layout/.phtml文件中添加代码,所以使用frontcontroller插件会更好。

    1 回复  |  直到 14 年前
        1
  •  5
  •   webbiedave    14 年前

    为什么不使用Smarty使用的regex呢。很简单:

    function strip($str, $replace = ' ')
    {
        return preg_replace('#\s+#', $replace, $str);
    }