PHP Output Buffering

一个人想着一个人 提交于 2019-12-22 04:19:49

问题


What are the methods to turn on output buffering either within a PHP script or using and htaccess file?

I use the following method in an htaccess file in the root of my application:

php_value output_buffering On
php_value output_handler mb_output_handler

On one of my shared hosting accounts (linux hosting with PHP 5.2.x), the above yields a blank page. Tech support says they can't turn it on in the php.ini file but I can turn it on in my script...

ob_start() and ob_end_flush() also yields the same result. What can I do?


回答1:


Use ob_start() and ob_end_flush().

ob_start() at the start of the script before any output (not even an empty space).

When u want to output use ob_end_flush().




回答2:


Check your PHP.ini file and ensure the Output Buffer is enabled.

After that, you can use ob_start() whenever you want to begin buffering and ob_flush() to flush the buffer whenever you want to stop buffering.



来源:https://stackoverflow.com/questions/4620977/php-output-buffering

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!