note 49951 added to function.ob-start

From: Date: Sun, 13 Feb 2005 16:09:21 +0000
Subject: note 49951 added to function.ob-start
Groups: php.notes 
Request: Send a blank email to php-notes+get-84924@lists.php.net to get a copy of this message
I use this function for deleting not needed characters within the html code before sending the whole stuff to the browser. function callback($buffer){ $buffer = str_replace("\n", "", $buffer); $buffer = str_replace("\t", "", $buffer); $buffer = str_replace(chr(13), "", $buffer); $buffer = ereg_replace("<!\-\- [\/\ a-zA-Z]* \-\->", "", $buffer); return $buffer; } First str_replace will delete any newlines, second any tabs and the third any carriage return. Finally the regular expression will delete any html-comment which consists of /, space, a-z or A-Z. Using this saves about 1kb on every pageload. ---- Manual Page -- http://www.php.net/manual/en/function.ob-start.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49951 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49951&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49951&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49951&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49951&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49951&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49951&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#84924) next »