开发者

How to compress HTML output except on a certain div?

开发者 https://www.devze.com 2023-02-07 08:31 出处:网络
I\'d like to use this function: ob_start(\'no_returns\'); function no_returns($a) { 开发者_开发百科return str_replace(

I'd like to use this function:

ob_start('no_returns');
 function no_returns($a) { 
开发者_开发百科  return str_replace(
   array("\r\n","\r","\n","\t",'','',''), 
   '', $a);
 }

But when I do, it completely kills Disqus comments so I'd like to ignore the DIV "disqus_thread". How would I go about doing that without using some heavy search?


If you are looking to speed up the download of the web page, you might try another method:

<?php

ob_start('ob_gzhandler');
// html code here

This will compress the output in a much more efficient manner and your browser will automatically decompress the output in real-time before the visitor sees it.

A related thread on-line is here: http://bytes.com/topic/php/answers/621308-compress-html-output-php

(This is the PHP way to compress web pages without using the webserver configuration. For example apache+gzip/mod_deflate on apache as mentioned above)


Try Regular Expression and preg_replace

0

精彩评论

暂无评论...
验证码 换一张
取 消