0

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 文件添加代码,所以前端控制器插件会很好。

4

1 回答 1

5

为什么不直接使用 Smarty 使用的正则表达式。这很简单:

function strip($str, $replace = ' ')
{
    return preg_replace('#\s+#', $replace, $str);
}
于 2010-10-26T23:31:28.087 回答