编程语言
首页 > 编程语言> > PHP ob_start()问题

PHP ob_start()问题

作者:互联网

我允许有两个或更多ob_start();在我的php文件中,如果是这样,结束一个ob_start()的正确方法是什么;并开始另一个?

解决方法:

从手册:

Output buffers are stackable, that is,
you may call ob_start() while another
ob_start() is active. Just make sure
that you call ob_end_flush() the
appropriate number of times. If
multiple output callback functions are
active, output is being filtered
sequentially through each of them in
nesting order.

除了堆叠(嵌套)之外,您还可以按顺序使用单独的块.

<?
ob_start();
echo "Foo";
ob_end_flush(); // outputs buffer contents and turns off output buffering

ob_start();
echo "Bar";
ob_end_flush();
?>

标签:php,output-buffering
来源: https://codeday.me/bug/20190606/1189531.html