>  기사  >  백엔드 개발  >  弃用ob_start~

弃用ob_start~

WBOY
WBOY원래의
2016-06-06 20:48:43857검색

content.php

<code class="lang-php">ob_start();
OOXX;
$ooxx = ob_get_clean();
</code>

template.php

<code class="lang-php">echo $ooxx;
</code>

原作用ob_start函数把OOXX的内容输出到template,有替代的方法吗?这个好像很占内存,我觉得没必要缓冲~

查到了,可以解析变量,函数不行,我还是将就着用吧~ http://thinkdiff.net/php/alternative-way-of-assigning-html-in-php-php-tips/

content.php

<code class="lang-php">$ooxx    =   </code>

template.php

<code class="lang-php">echo $ooxx;
</code>

回复内容:

content.php

<code class="lang-php">ob_start();
OOXX;
$ooxx = ob_get_clean();
</code>

template.php

<code class="lang-php">echo $ooxx;
</code>

原作用ob_start函数把OOXX的内容输出到template,有替代的方法吗?这个好像很占内存,我觉得没必要缓冲~

查到了,可以解析变量,函数不行,我还是将就着用吧~ http://thinkdiff.net/php/alternative-way-of-assigning-html-in-php-php-tips/

content.php

<code class="lang-php">$ooxx    =   </code>

template.php

<code class="lang-php">echo $ooxx;
</code>

ob_start很耗CPU而不是内存?头一回这么听说这么个形容这个函数的性能的。兄台,老老实实用吧!!目前没有替代方案

如果你不需要在输出前替换内容,那你完全可以不用,直接输出。替换方案目前没有。。。

不知道为啥这么用。我是在渲染模板的时候调用的obstart。即在 $this->view->render();

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.