Getting error
PHP Notice: Undefined variable: do_not_compress
in my php code.
session_start();
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && !$do_not_compress) {
ob_start('ob_gzhandler');
} else {
ob_start();
}
I tried to remove the && !$do_not_compress
then throw another error
PHP Warning: ob_start(): output handler 'ob_gzhandler' cannot be used twice.
PHP Warning: ob_start(): failed to create buffer
Please help to fix this issue.
Firstly, if $do_not_compress has not been set before it reaches this point then it's not going to be able to observe the value of it. If you're trying to use ! to see if it's not been set yet, then you should be using isset().
Secondly, I haven't used ob_start() but it appears to be that you can't call "ob_start('ob_gzhandler');" more than once in your code. So to fix the error there, don't. Here's something that may help you check before calling: How to determine wether ob_start(); has been called already
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments