PHP output buffering

What are the methods to enable output buffering in either the PHP script file or the use and htaccess file?

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

php_value output_buffering On php_value output_handler mb_output_handler 

On one of my hosting accounts (linux hosting with PHP 5.2.x) the above gives a blank page. Technical support says that they cannot include it in the php.ini file, but I can include it in my script ...

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

+8
php output-buffering
source share
2 answers

Use ob_start() and ob_end_flush() .

ob_start() at the beginning of the script before any exit (not even empty space).

When you want to output, use ob_end_flush() .

+6
source share

Check the PHP.ini file and make sure the output buffer is enabled.

After that, you can use ob_start() when you want to start buffering, and ob_flush() to ob_flush() buffer when you want to stop buffering.

+2
source share

Source: https://habr.com/ru/post/650781/


All Articles