dongluanban3536 2010-09-04 09:13
浏览 35
已采纳

ob_get_level()从1级开始

Having a few problems with output buffering. Mainly, I'm trying to run output buffering with the ob_gzhandler callback, but it keeps telling me its using an unsupported compression type. Everything is enabled, and I believe the problem is that running ob_get_level() at the start of my script produces a level of 1. php.ini has my output_buffering set to 4096.

If I run something like:

while(ob_get_level() > 0){
   ob_end_clean();
}

Then I can successfully run ob_start() with the ob_gzhandler callback. But I'm wondering if it should be a problem. During my script I make calls to ob_clean() at various points as I'm avoiding stacking too many buffers as I've read this can increase performance. I'm just unsure as to what I should be doing here.

Cheers.

  • 写回答

1条回答 默认 最新

  • douyangcheng4965 2010-09-04 09:19
    关注

    You have output buffering enabled by default (see the docs) - that basically means that every PHP script starts with ob_start().

    If you want to disable the default OB for all PHP scripts, in your php.ini, set output_buffering = Off.

    If you only want to disable the default OB for this specific script, use the while loop - it's quite correct.

    As for the ob_clean - are you sure you want to delete the output that's in your buffer? IMO it's not really necessary, unless you are seeing significant slow page loads. Don't worry about optimizing that (at least not now).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图