php – 如何在类中启动ob_start?
发布时间:2020-12-13 22:13:06 所属栏目:PHP教程 来源:网络整理
导读:我正在做一些关于从 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_flu
我正在做一些关于从
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(函数)?我们可以像ob_start($this-> compresssor())那样做吗? (好吧,我知道它失败了)在课堂上?任何人 ?? 谢谢你的关注. 亚当拉马丹 解决方法ob_start(array($this,'compressor')) PHP使用array(instance,function) representation将类的成员函数表示为可调用函数. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |