output-buffering

Flush output buffer in Apache/Nginx setup

守給你的承諾、 提交于 2019-12-12 10:39:56
问题 I would like to have page content for a web page I am developing appear on screen as it is downloaded. In my test/development environment this works as expected using the PHP flush() command. However, my production setup (WPEngine) uses an Nginx proxy in front of Apache and flush() no longer works (nor do any of the other output buffering commands). I have been able to get the desired behaviour by deliberately filling up the buffer when I want to flush by sending 4k worth of whitespace.

How to determine wether ob_start(); has been called already

天涯浪子 提交于 2019-12-12 08:24:51
问题 I use output buffering for gzip compression and access to what was put out before in a PHP script: if(!ob_start("ob_gzhandler")) ob_start(); Now if that script gets included in another script where ob_start() already is in use I get a warning: Warning: ob_start() [ref.outcontrol]: output handler 'ob_gzhandler' cannot be used twice in filename on line n So I'd like to test wether ob_start() has already been called. I think ob_get_status() should be what I need but what is the best way to use

ob_flush not working

老子叫甜甜 提交于 2019-12-12 04:43:49
问题 I searched in all question, I got all answers and suggestions, but none of them helped me. He's my code: <?php ini_alter("memory_limit", "1024M"); ini_set('display_errors', 0); ini_set('implicit_flush', 'On'); //Inutil já que usa a funcao,, mas vamo testar error_reporting(0); set_time_limit(0); ob_implicit_flush(true); ob_end_clean(); while (ob_get_level()) ob_end_flush(); ob_start(); for ($i = 0; $i < 5; $i++) { echo $i . '<br>'; ob_flush(); flush(); sleep(5); } echo ini_get('ob_implicit

how can i find out if the php output already started? [duplicate]

限于喜欢 提交于 2019-12-12 03:45:28
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: PHP: how to know if output already started? I would like to find out if there is already generated output in the buffer before I start the session. In PHP, an output that started before the session started always creates a warning, for example a bug in the controller creates this output: Warning: fopen(/tmp/test.txt) [function.fopen]: failed to open stream: Permission denied in /var/www/app/controllers/test

PHP Streaming/Output Buffering no longer working

荒凉一梦 提交于 2019-12-12 03:16:15
问题 I have a script that used to work in PHP5.3 to handle buffering for a particular log file but after the server was upgraded to PHP5.5 it no longer works. The output needs to be html so I was hoping to simply flush output after each echo. This is a cut-down test version of the code that used to work... @apache_setenv('no-gzip', 1); @ini_set('zlib.output_compression', 0); @ini_set('implicit_flush', 1); for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); } ob_implicit_flush(1); set_time

Output buffering and AJAX

夙愿已清 提交于 2019-12-11 18:21:56
问题 When a user clicks a button on my site, a particular part of a page will be refreshed, but it takes a while to render the entire section. Is it possible to display/output parts of the section in real time rather than wait for the entire section to finish? How would i do this if im sending it as an ajax request for html content? Thanks 回答1: I would recommend setting cache: true in your AJAX call (if using jQuery) and either way, you're going to want to set the HTTP response headers. Here are

Setting HTTP headers to be able to run test cases

China☆狼群 提交于 2019-12-11 10:48:48
问题 I am using phpunit. I want to test my code which basically gets parameters from HTTP headers and use it to perform subsequent operations. But while testing the headers are null. Is there any way to set headers (may be in bootstrap file) so that when my code accesses parameter it gets that value? UPDATE : I tried below code as suggested in this question: class Action_UserTest extends PHPUnit_Framework_TestCase { /** * @runInSeparateProcess */ public function testBar() { header('Location : foo'

PHP file_put_contents doesn't work as expected within in register_shutdown_function()

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 10:27:36
问题 I am playing with output buffering in my script and stumbled upon unexpected behaviour. Writing to a file works everywhere else in my script, but it doesn't quite do so after entering the register_shutdown_function()-function. I get a warning telling me I don't have permission to write to the file. So I checked which path I was in. Apparently the current working directory vanishes from the moment you enter the shutdown function. My question is not particularly on how to solve this; As you can

set OutputStream for a process

半城伤御伤魂 提交于 2019-12-11 09:55:50
问题 Here is a snipped code of my problem: Process process = Runtime.getRuntime().exec(command); if (process.waitFor() != 0) throw new Exception("error"); reader = new BufferedReader(new InputStreamReader(process.getInputStream())); The running process is producing a huge output. If i redirect the output to a file, the process terminates quicker then printing the output on screen (standard output). I do not wish to redirect the output to a file, due to low performance of the disk, filesystem

Necessity of prefixing all PHP pages with ob_start()

旧时模样 提交于 2019-12-11 02:40:03
问题 Is it OK to have ob_start() in the beginning of all PHP pages? If I don't do this, I get the "headers already sent" error. 回答1: It is "ok" but you should really fix your script to not output stuff prematurely and save the output for the end. But you can just change a setting in .htaccess or the php.ini the below is the for .htaccess: php_value output_buffering On php_value output_handler mb_output_handler This would be preferred, in my opinion, instead of adding ob_start to the top of all