Does it make sense to strip newlines, tabs, extra spaces, etc. from a scripts' output? It should reduce the page size a bit and obfuscate the HTML.
What would be the best way to do this?
Thanks!
Stormfx
5:24 am on May 16, 2005 (gmt 0)
You can do this, I suppose. Just remember that certain things do require spaces. For example, to assign multiple CSS classes to an HTML element, the class names have to be seperated by a space. But you can use str_replace to do what you need.
tkroll
5:32 am on May 16, 2005 (gmt 0)
Yes, of course you are correct. I meant to say replace multiple space sequences with a single space.
The only way is to use output buffering, right?
Stormfx
6:02 pm on May 16, 2005 (gmt 0)
Yeah, if your output is spit out at different times, ob is the way to go. <?php
// start if (ob_get_levels() == 0) { ob_start(); }
// code...
// end $content = ob_get_contents(); ob_end_clean();
// use str_replace to do what you need
echo $content;
tkroll
1:08 am on May 17, 2005 (gmt 0)
Cool! That is what I thought. There is no way to do it without output buffering?