output-buffering

ob_flush takes long time to be executed

▼魔方 西西 提交于 2019-12-22 03:44:10
问题 In my website(running with drupal) the ob_flush function takes a long time(between 10 - 100 secs) to be executed. How do I find out why? What can cause this so long time? 回答1: Try this: ob_start(); //Your code to generate the output $result = ob_get_contents(); //save the contents of output buffer to a string ob_end_clean(); echo $result; It is run quick for me. 回答2: [You may want to tag your question with Drupal, since this feels like it might be a Drupal issue. Specifically, I suspect that

How to correctly show output at every echo on all browsers?

穿精又带淫゛_ 提交于 2019-12-21 04:33:30
问题 I moved my files to a new server and I had a script that instantly showed output on every echo to the browser, but this isn't working on the new server. Here is my test code: @ini_set('output_buffering', 0); @ini_set('implicit_flush', 1); for ($i = 0; $i < ob_get_level(); $i++) ob_end_flush(); ob_implicit_flush(1); ignore_user_abort(true); set_time_limit(0); $max_wait_time = 30; $begin_time = microtime(true); $elapsed_time = 0; while(!connection_aborted()) { echo $i++.str_repeat(' ', 1020).'

If you flush the content (ob_flush) of an AJAX request, the content will get loaded?

£可爱£侵袭症+ 提交于 2019-12-18 16:53:10
问题 I mean... Let's that we just make an AJAX request and inser the result inside a div#result.. In the backend the script use ob_flush() to send the header but not terminate the request until it's terminated (with exit or ob_flush_end ) The content will be loaded into the #result only when the request terminate ( exit or ob_flush_end ) or it'll be loaded every time the script send the header by ob_flush ? Update: I'll use jQuery load() to make the request & PHP to answer it 回答1: Yes, content

PHP - htaccess - output_buffering

末鹿安然 提交于 2019-12-18 06:16:24
问题 I have the following code in an htaccess file in my application root to turn output buffering on. php_value output_buffering On php_value output_handler mb_output_handler On some servers it causes a 500 internal error, on others it works fine. Does anyone know why it sometimes causes an error. Is there a different way to do this? Thank you! 回答1: You can use this syntax only if PHP is running as an Apache module. The 500 errors probably come up on servers where this is not the case. For total

PHP - How Detect if Output Buffering is Turned On

孤街浪徒 提交于 2019-12-17 20:07:44
问题 Is there a simple way to detect in PHP if output_buffering is ON in php.ini? I'd like to be able to display a message if it is not turned on. Within my application I tried using an htaccess file to automatically turn it on but it seems it does not work in all server environments and in some cases it gives a nasty error. Thank you very much! 回答1: You can check any INI setting in PHP with the ini_get method. http://php.net/ini_get ini_get('output_buffering'); Likewise, you can change most INI

PHP buffer ob_flush() vs. flush()

ⅰ亾dé卋堺 提交于 2019-12-17 02:29:36
问题 What's the difference between ob_flush() and flush() and why must I call both? The ob_flush() reference says: This function will send the contents of the output buffer (if any). The flush() reference says: Flushes the write buffers of PHP and whatever backend PHP is using (CGI, a web server, etc). However, it continues to say: [it] may not be able to override the buffering scheme of your web server… So, seems to me that I could just use ob_flush() all of the time. However, I get strange

Redircting to a page in PHP [duplicate]

夙愿已清 提交于 2019-12-14 04:24:23
问题 This question already has answers here : How to fix “Headers already sent” error in PHP (11 answers) Closed 6 years ago . I am trying to make a redirect to page based on its referrer. the layout is like <?php $URL_REF = $_SERVER['HTTP_REFERER']; if($URL_REF == "url of my site") { header("Location: url of another site"); exit(); } else { header("Location: my home page"); exit(); } ?> I am getting the error : Cannot modify header information - headers already sent by . I have to modify my php

Continue php script after connection close

♀尐吖头ヾ 提交于 2019-12-14 03:39:45
问题 I am trying to continue a PHP Script after the page/connection is closed. Users will POLL the script in every 1 hour, I want to return some json output and want to continue the script in the background. I am using a shared host and I cannot use cron job. Here is what I've tried. ob_start(); ignore_user_abort(); echo "JSON_OUTPUT GOES HERE"; $ob_length = ob_get_length(); header("Content-Type : text/plain",TRUE); header("Content-Length : $ob_length",TRUE); header("Connection : Close",TRUE);

Line-buffering of stdout fails on MINGW/MSYS Python 2.7.3

元气小坏坏 提交于 2019-12-12 18:19:39
问题 The problem is illustrated by this simple script: import time, os, sys sys.stdout = os.fdopen( sys.stdout.fileno(), 'w', 1 ) # line-buffer stdout print 'before sleep' time.sleep( 10 ) print 'after sleep' If line-buffering is successful, then there will be a 10-sec gap between the printing of the two lines. If not, both lines will appear virtually at the same time after a 10-sec pause (once Python starts up); that is, the lines are printed when the program exits. On Linux, I see line-buffered

How can an output buffer worsen performance

纵饮孤独 提交于 2019-12-12 17:05:40
问题 I am writing a php script and somewhere before my header() function i have printed text to the browser hereby causing my header() function give me a well known error: Warning: Cannot modify header information - headers already sent. Now my question is, I have the intentions of using ob_start() and ob_flush() before and after the header() function. But I once heard something like output buffer can affect the performance of one's application negatively. How true is that? Or should I just stick