I want to compress spaces. the following template code is available: the upper and lower p templates. I like the p method above. because the indentation and matching are good, the following writing method will make it difficult to read and maintain.
aafdsa
">
">
View object control code is like this
$ar1 = array(1,2,3,4,5,6,7); //extract($this->data);ob_start('ob_gzhandler');ob_implicit_flush(0);include 'tpl.php';ob_flush();
However, the output HTML is as follows (only the BODY part is attached below)
1 2 3 4 5 6 7
1234567
I tried to use the typographical standard writing method, but I tried to output the following p2 a label without line breaks. I don't know if this can be achieved. I thought
Ob_start ('OB _ gzhandler ');
This setting can be compressed, but it does not.
I wondered how the thinkphp framework got it. I standardized the typographical template code in it, but it compressed the output. it may be because of its compilation. I don't have statistics, just include...
Is there any way to guide this? Compilation required?
Reply to discussion (solution)
Ob_start ('compact _ format'); function compact_format ($ buffer) {return preg_replace ("/[\ r \ n] + \ s */",'', $ buffer);} echo <TXT1 2 3 4 5 6 7
TXT; // run the following command to check the effect.
Ob_start ('compact _ format'); function compact_format ($ buffer) {return preg_replace ("/[\ r \ n] + \ s */",'', $ buffer);} echo <TXT1 2 3 4 5 6 7
TXT; // run the following command to check the effect.
Well, thank you. you can execute the regular expression.
I thought PHP's built-in output mechanism could be used.