我正在做一些关于从 php 最小化 html 的研究。喜欢
class themeing
{
function render( $file, $folder )
{
if ( COMPRESS ) {
// this is the problem
ob_start('compressor');
}
$get = VIEWS . $folder . '/' . $file . '.phtml';
if ( COMPRESS ) {
ob_end_flush();
}
return $get;
}
function compressor($buffer)
{
$search = array(
'/<!--(.|\s)*?-->/',
'/\>[^\S ]+/s',
'/[^\S ]+\</s',
'/(\s)+/s'
);
$replace = array(
'',
'>',
'<',
'\\1'
);
$buffer = preg_replace($search, $replace, $buffer);
return $buffer;
}
}
问题是我怎么称呼这个 ob_start(function) ?我们可以像 ob_start($this->compresssor()) 一样吗? (好吧,我知道它失败了)在类里面?任何人 ??
谢谢你进来看看。
亚当·拉马丹
最佳答案
关于php - 如何在类内启动 ob_start?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3940869/