Firefox Tip: Content encoding error cannot display the page you are trying to view _php tutorial

Source: Internet
Author: User
Tags unsupported
Today to help customers to organize a website found in the Firefox Hint: Content encoding error cannot display the page you are trying to view, because it uses an invalid or unsupported compression format, I look at the customer is PHP station, cause may be ob_gzhandler reasons, the following I summarize the solution.

Firefox error code:

Content encoding Error

The page you are trying to view cannot be displayed because it uses an invalid or unsupported compression format.

Please contact the owner of the site to inform this question


Causes of errors and solutions:

1, ensure that the PHP program does not have any warning or error prompts

2, PHP code ob_start (' Ob_gzhandler ') caused by the cause of two kinds of reasons:
A, the server does not support this compression format, can use Function_exists (' Ob_gzhandler ') judgment, the solution ob_start (' Ob_gzhandler ') changed to Ob_start ();
B, use Ob_start (' Ob_gzhandler ') when there is already content output, check the contents of the previous content and require include call file. If unable to find can use Ob_start () before calling other files, use Ob_end_clean () to clear the output after the call;

3. Set_magic_quotes_runtime () function:
Hint: function set_magic_quotes_runtime () is deprecated, the reason for this hint is that this feature has been closed after PHP5.3, and the feature has been completely removed in PHP6, that is, the function is no longer present. You can either comment or delete the line that went wrong, or add the @ sign before set_magic_quotes_runtime ().

4, PHP5.30 version, the default is no longer support such syntax, output variables need to use the PHP echo $username; > grammar is only possible. You can do this by setting the Short_open_tag in php.ini to on to be compatible with the original syntax.

PHP about Ob_start (' Ob_gzhandler ') enable gzip compression for bugs

If using Ob_start ("Ob_gzhandler");
The output after Ob_clean () will not be displayed, which is a bug,
can be used Ob_end_clean (); Ob_start ("Ob_gzhandler"); Instead of Ob_clean ();
Otherwise, the output will be empty.
Error_reporting (E_all);
Ob_start ("Ob_gzhandler");
echo "Content";
Ob_clean ();
echo "More content";
?>
The above code expects the output to be more content and nothing is actually output.

It's normal down here.
Error_reporting (E_all);
Ob_start ("Ob_gzhandler");
echo "Content";
Ob_end_clean ();
Ob_start ("Ob_gzhandler");
echo "More content";
?>

Here's a custom callback function to test again
function My_ob_gzhandler ($buffer, $mod) {
Header ("Content-encoding:gzip");
Return Gzencode ($buffer, 9, force_gzip);
}

Error_reporting (E_all);
Ob_start ("My_ob_gzhandler");
echo "Content";
Ob_clean ();
echo "More content";
?>
The above is normal, but using Ob_end_clean instead of Ob_clean will cause the output to be displayed later.

Therefore, even the following code will cause the output to be empty after using Ob_clean or Ob_end_clean.
if (Ini_get (' zlib.output_compression ')) {
if (Ini_get (' zlib.output_compression_level ')! = 9) {
Ini_set (' Zlib.output_compression_level ', ' 9 ');
}
Ob_start ();
} else {
if (strstr ($_server[' http_accept_encoding '), "gzip")) {
Ob_start ("Ob_gzhandler");
} else {
Ob_start ();
}
}
?>

The most stable method of enabling page compression should resemble the following
if (extension_loaded (' zlib ')) {
Ini_set (' zlib.output_compression ', ' on ');
Ini_set (' Zlib.output_compression_level ', ' 3 ');
}
?>

However, if you must use Ob_gzhandler to enable page compression pay attention to the first sentence of this article.

In fact, the following code is just the browser does not display
Error_reporting (E_all);
Ob_start ("Ob_gzhandler");
echo "Content";
Ob_clean ();
echo "More content";

But if you test it,

telnet localhost 80
get/test.php http/1.0

The following information will be returned

http/1.1 OK
Date:fri, 15:40:17 GMT
server:apache/2.2.6 (WIN32) php/5.2.5
x-powered-by:php/5.2.5
Vary:accept-encoding
Content-length:12
Connection:close
Content-type:text/html

More content

The connection to the host has been lost.

You can see that more content has been output

http://www.bkjia.com/PHPjc/632098.html www.bkjia.com true http://www.bkjia.com/PHPjc/632098.html techarticle today to help customers to organize a website found in the Firefox Hint: Content encoding error cannot display the page you are trying to view, because it uses invalid or unsupported compression format, I ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.