Getting error PHP Notice: Undefined variable: do_not_compress in my php code

finatems Technologies

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.

Maytch

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.

edited at
0

Comments

0 comments
Login to comment

Related

PHP Notice: Undefined variable

PHP Notice: Undefined variable:

PHP MySql - Notice: Undefined variable Error

PHP error undefined variable notice how to fix?

Not able to fix "PHP Notice: Undefined variable" and "Undefined index" in code

Notice: Undefined variable: id in PHP

PHP error: Notice: Undefined offset

getting notice if my php session is not set. how to resolve this? (<b>Notice</b>: Undefined index: myname...)

I am facing an Undefined Variable:Notice Error in PHP

A PHP Error was encountered Severity: Notice Message: Undefined variable: result

Notice: Undefined variable - WordPress / Parse Server Plugin - PHP Error

"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP

PHP Notice: undefined variable, but they are already defined

php warning session variable, Notice: Undefined index:

Notice: Undefined variable: grandTotal in PHP 7.1

"Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset" using PHP

PHP Notice: Undefined index and Form Fields error

PHP Notice: Undefined index

Undefined index notice in php

PHP Notice: Undefined offset

PHP Notice: Undefined index

Ngnix - FastCGI sent in stderr: "PHP message: PHP Notice: Undefined variable

Getting an undefined variable error for variable defined within function in php

PHP Notice: Undefined offset: 1 while getting all directories

php Getting sum arrays, but have "Notice" Undefined offset: 0

PHP Notice: Undefined offset: 39 in /my/path/*.phpFile on line 23

Notice: Undefined variable: world in abc.php on line

Notice : Undefined variable: result in new_admin.php on line 42

PHP Notice: Undefined variable in array_walk_recursive function