gpt4 book ai didi

PHP ob_start() 问题

转载 作者:可可西里 更新时间:2023-10-31 22:48:50 25 4
gpt4 key购买 nike

我是否允许在我的 php 文件中有两个或多个 ob_start(); 如果是的话,结束一个 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.

除了堆叠(嵌套)之外,您还可以按顺序拥有单独的 block 。

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

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

关于PHP ob_start() 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4061433/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com