note 49951 deleted from function.ob-start by cmb

From: Date: Sun, 14 Jul 2019 11:24:53 +0000
Subject: note 49951 deleted from function.ob-start by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211572@lists.php.net to get a copy of this message
Note Submitter: eddie ---- 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.

« previous php.notes (#211572) next »