• PHP Help PHP Coding
  • [RESOLVED] $_SERVER['HTTP_ACCEPT_ENCODING'] and notice in the xhtml service validation .......

Hi.
I've got a snippet like this:

if(strpos($_SERVER['HTTP_ACCEPT_ENCODING'],'gzip')===false){
	echo $indexController->getPage();
}
else{
    	ob_start();
    	echo $indexController->getPage();
    	$output=gzencode(ob_get_contents(),9);
   	ob_end_clean();
    	header('Content-Encoding: gzip');
	echo $output;
	unset($output);
}

Why on earth I've got this notice:

<br />
<b>Notice</b>: Undefined index: HTTP_ACCEPT_ENCODING in <b>/mounted-storage/home50a/sub001/sc19485-LOWM/www/blogialnewversion/index.php</b> on line <b>25</b><br />

that waste all the validation process.
At the http://www.blogial.net/blogialnewversion/index.php there isn't notice 😕

Best wishes 😉

    Thanks a lot buddy.
    Do you know any workaround for that ?
    By the way is there a better way to gzip output buffer ?

    Bye.

      <?php
      // before any output:
      ini_set('zlib.output_compression', 1);
      

      Or set it in your php.ini file or in a local .htaccess file if you want to apply it globally or by directory tree to all PHP files.

        Write a Reply...