The below code is not printing anything in the browser. actually, It should show the header menu.
if I remove ob_start(); and
ob_end_clean() at least its printing menu without CSS.
// Turn on output buffering HTML
ob_start();
echo preg_replace( '/n|t/i', '', implode( '' , $wr_nitro_header_html ) );
WR_Nitro_Header_Builder::prop( 'html', ob_get_contents() );
ob_end_clean()
update: same code is working fine for php7.4
but php8.1 is not working
2
Answers
Your theme may not be compatible with 8.1, as there are several breaking changes introduced when migrating from 7.4 to 8.1. Try adding:
to your wp-config.php file and see if errors print to the DOM, or make the display false and check debug.log if you are concerned about printing errors.
Then, reach out to the theme company directly and asking if they are compatible with PHP 8.1.
There is a compatibility issue because the Output Buffering has been changed in PHP 8.1
In PHP 8.1. you have to use the new aliases instead of using the PHP 7.4
ob_*
functions.For example:
Alternatively, you can use the
OutputControl
namespace like that: