note 77185 deleted from function.ob-start by nlopess
| From: | nlopess@php.net | Date: | Sat, 01 Sep 2007 11:58:51 +0000 |
| Subject: | note 77185 deleted from function.ob-start by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-129998@lists.php.net to get a copy of this message | ||
Note Submitter: Sam Yong - hellclanner [at] live dot com
Reason: spam
----
A simple function to remove all newlines, tabs, formfeed from your HTML output. You can save some
bandwidth with this. Also, it removes all HTML comments within the HTML document.
To prevent the conflict for displaying newline in textareas, use \n instead of \r\n in textareas to
display newlines in textareas properly.
<?php
function ob_WSR($buffer){
$buffer = preg_replace('
(\<\!\-\-(.*?)\-\-\>)is', '',
$buffer);
$buffer = preg_replace('(\r\n|\r|\t)is', '', $buffer);
chdir(dirname($_SERVER['SCRIPT_FILENAME']));return $buffer;}
ob_start('ob_WSR',strlen(ob_get_contents()));
?>
Used successfully on http://betapod.hellclanner.com/