用户评论:

[#1]

nico (at) nokes.de [2012-08-26 16:24:37]

best way to compress a css code:

header('Content-type: text/css');ob_start("compress");

functioncompress($buffer) {// remove comments$buffer=preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!','',$buffer);// remove tabs, spaces, newlines, etc.$buffer=str_replace(array("\r\n","\r","\n","\t",'  ','    ','    '),'',$buffer);

return$buffer;

}

include('./template/main.css');

include('./template/classes.css');

ob_end_flush();?>

Include in

:

[#2]

anatoliy at miraline dot com [2011-04-11 09:06:15]

If you enable zlib.output_compression then level count will be increased by 1 and then this code:

will just freeze your script.

[#3]

Mark [2010-06-24 13:49:41]

Wanted to speed things up and put some processing after the page has been delivered to the client. That drove me almost insane, but finally, I found a solution (php 5.2.5):

ob_start();// outer bufferob_start();// inner buffer to catch URL rewrites and other post processingsession_start();// registers URL rewriter with inner buffer!echo'...';// log performance data to log files *after* delivering the page!register_shutdown_function(array($benchmarkclass,'log_perf_data'));// now flush output output to clientob_end_flush();// need to calculate content length *after* URL rewrite!header("Content-length: ".ob_get_length());ob_end_flush();// now we close the session and do some arbitrary clean-up tasks

// registered using register_shutdown_function()session_write_close();?>

[#4]

unxed [2010-03-06 06:50:03]

Remember that chromium browser (and maybe other webkit-based browsers) have some issues with ob_end_flush.

http://code.google.com/p/chromium/issues/detail?id=31410

You may use

header("Content-Type: text/plain");

to solve those issues if you do not need html.

[#5]

shanep [2010-01-21 21:31:12]

It appears that ob_end_flush() is very important if you are looping.  For instance if you are using a mass mailer that uses the output buffer for creating HTML content.  Use ob_end_flush() to avoid server errors.

[#6]

skippy at zuavra dot net [2005-07-01 02:10:53]

Apart from being mostly redundant, ob_end_flush() can be downright damaging in some weird cases.

Actual example: a particular page on an Intranet website which would appear blank on Internet Explorer 6 when ob_start('ob_gzhandler') was called in the beginning and ob_end_flush() at the end.

We couldn't figure out what made that page special no matter what we tried. The ob_ functions were placed in scripts which were include()'d by all pages just the same, but only that page did this.

Even stranger, the problem only appeared on direct browser/server connections. Whenever the connection passed through a proxy the problem dissapeared. I'm guessing some kind of HTTP encoding headers mumbo-jumbo.

Solution: unless you really need it in particular cases, remove the ob_end_flush() call and rely on the builtin, automatic buffer flush.

[#7]

jhannus at 128kb dot com [2004-06-05 09:18:45]

A note on the above example...

with PHP 4 >= 4.2.0, PHP 5 you can use a combination of ob_get_level() and ob_end_flush() to avoid using the @ (error suppresion) which should probably be a little faaster.

<?phpwhile  (ob_get_level() >0) {ob_end_flush();

}?>

[#8]

kriek at jonkriek dot com [2003-03-29 09:22:32]

ob_end_flush() isn't needed in MOST cases because it is called automatically at the end of script execution by PHP itself when output buffering is turned on either in the php.ini or by calling ob_start().

[#9]

brett at realestate-school dot com [2002-09-26 13:01:16]

It appears that you can call ob_end_flush() regardless of whether or not output buffering was ever started using ob_start(). This can prove useful because it saves you from having to create conditional statements based on whether a particular function or include file has started output buffering. You can simply call the ob_end_flush() anyway and if there's output in the buffer, it will be sent, otherwise your script will just keep on keepin' on.

php endall(),ob_end_flush相关推荐

  1. php endall(),从G_BEGIN_DECLS和 G_END_DECLS说起

    今天开始正式研究gedit的源码,第一次看c/c++的源码,有点吃力啊,坚持不懈,慢慢来. 在gedit.c文件中遇到了G_BEGIN_DECLS和G_END_DECLS,平常搞C语言的东西,我个人几 ...

  2. 基于php下载文件的详解

    基于php下载文件的详解 本篇文章是对php下载文件进行了详细的分析介绍,需要的朋友参考下 php下载文件,比如txt文件. 出现的效果就是,弹出浏览器自带的下载框,出现另存为操作.有时候会出现内存溢 ...

  3. php 缓冲区,PHP的输出缓冲区

    PHP的输出缓冲区 在PHP中有一个名为"输出缓冲区"「ob」的东西.PHP的输出流包含很多字节,通常是echo语句或者printf()函数输出的.这些东西的数据需要用到输出缓冲区 ...

  4. php ob_flush无效,php ob_flush,flush在ie中缓冲无效的解决方法

    PHP程序的缓冲,而不论PHP执行在何种情况下(CGI ,web服务器等等).该函数将当前为止程序的所有输出发送到用户的浏览器. flush() 函数不会对服务器或客户端浏览器的缓存模式产生影响.因此 ...

  5. 剖析PHP中的输出缓冲

    剖析PHP中的输出缓冲 本文按署名·非商业用途·保持一致授权 作者:  ,发表于2005年12月24日01时54分 我们先来看一段代码. <?php for ($i=10; $i>0; $ ...

  6. output_buffering详细介绍

    HTTP Header 为什么要使用Output Buffering技术 Output Buffering的工作原理 基本用法 高级用法 使事情更为简单 哈哈,我成功了 我个人认为,Output bu ...

  7. php导出excel(xls或xlsx)(解决长数字显示问题)

    1)demo $titles = array('订单号','商品结算码','合同号','供应商名称','专柜','商品名称','商品货号','商品单价','商品总价','供应商结算金额','商品数量' ...

  8. php动态语言静态化

    2019独角兽企业重金招聘Python工程师标准>>> ob_start ob_implicit_flush ob_get_contents ob_end_clean ob_get_ ...

  9. 为什么php动态语言,动态语言静态化

    [TOC] ## 什么是动态语言静态化 将现有PHP等动态语言的逻辑代码生成为静态HTML文件,用户访问动态脚本重定向到静态HTML文件的过程. 对实时性要求不高的页面 ## 为什么要静态化 动态脚本 ...

最新文章

  1. 自动驾驶中高效的激光雷达里程计
  2. 005_Buzz播放音频
  3. c语言改java语言,请教怎么把这个JAVA程序改成C语言能够运行啊
  4. 摸透 Redis 主从复制、哨兵、Cluster 三种模式
  5. spark.mllib:回归算法
  6. Java测试驱动开发--总结
  7. tomcat 报错:Error occurred during initialization of VM
  8. 8.大数据架构详解:从数据获取到深度学习 --- 机器学习和数据挖掘
  9. PE+Dism++组合实现操作系统的备份恢复给力。
  10. 三菱GXWorks2 程序写入CPU之前准备工作
  11. LiveZilla 详细 配置 设置 (四) 查看成果及总结
  12. 微信公众账号高级接口使用小结
  13. 当遇到error: stray ‘\241‘ in program错误的解决方法
  14. 为什么工作三年的程序员还不懂APM与调用链技术?
  15. Python并发编程之进程池
  16. matlab为long term visual tracking数据集生成groundtruth.txt
  17. 好强型性格分析,如何改变好强型性格?
  18. 【python毕业设计源码】汽车销售系统
  19. 如何在程序中创建快捷方式?
  20. 电气设计参考图纸,有高低压电气设计图纸、自控设计图纸和污水处理工程电气自控图

热门文章

  1. java使用gridview,网格控件GridView在Android中的使用
  2. liunx 加入域控_让Linux使用Windows域控制器做用户认证
  3. XML能否替换HTML,XML DOM
  4. vb.net读取excel并写入dgv_如何用Python读取Excel中的图片?然后写入图片?
  5. matplotlib画散点图
  6. JavaScript实现backtracking Jump Game回溯跳跃游戏算法(附完整源码)
  7. OpenCASCADE:OCCT应用框架OCAF之标准属性
  8. wxWidgets:wxDataViewCtrl类用法
  9. BOOST_VMD_ASSERT_IS_LIST相关的测试程序
  10. boost::math模块计算 Bessel 和 Neumann 函数的零点的测试程序