I don't have any problem on localhost. but when i tested my codes on server, end of every page i see this notice.
my code:
<?php
ob_start();
include 'view.php';
$data = ob_get_contents();
ob_end_clean();
include 'master.php';
ob_end_flush(); // Problem is this line
WordPress attempts to flush the output buffers on shutdown. It fails because you have already called ob_end_flush()
.
You should be able to keep compression on, and simply unhook the flush action:
remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
You can now call ob_end_flush()
manually, and keep zlib compression on.
I wouldn't recommend disabling the wp_ob_end_flush_all()
function entirely, and I definitely wouldn't turn off zlib.output_compression
in your php.ini
file. Here's a better approach that replaces the source code causing the issue, and preserves the underlying functionality:
/**
* Proper ob_end_flush() for all levels
*
* This replaces the WordPress `wp_ob_end_flush_all()` function
* with a replacement that doesn't cause PHP notices.
*/
remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
add_action( 'shutdown', function() {
while ( @ob_end_flush() );
} );
More details on the cause, and why this is probably the best approach can be found here: Quick Fix for WordPress ob_end_flush() Error
It solved when switched off zlib.output_compression in php.ini
zlib.output_compression = Off
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With