note 77185 added to function.ob-start
| From: | SamYong-hellclanner | Date: | Sun, 19 Aug 2007 01:46:09 +0000 |
| Subject: | note 77185 added to function.ob-start | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129583@lists.php.net to get a copy of this message | ||
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/
----
Server IP: 202.79.178.91
Probable Submitter: 202.156.12.10 (proxied: 222.165.25.57)
----
Manual Page -- http://www.php.net/manual/en/function.ob-start.php
Edit -- https://master.php.net/note/edit/77185
Del: integrated -- https://master.php.net/note/delete/77185/integrated
Del: useless -- https://master.php.net/note/delete/77185/useless
Del: bad code -- https://master.php.net/note/delete/77185/bad+code
Del: spam -- https://master.php.net/note/delete/77185/spam
Del: non-english -- https://master.php.net/note/delete/77185/non-english
Del: in docs -- https://master.php.net/note/delete/77185/in+docs
Del: other reasons-- https://master.php.net/note/delete/77185
Reject -- https://master.php.net/note/reject/77185
Search -- https://master.php.net/manage/user-notes.php