Want to compress spaces.-php Tutorial

Source: Internet
Author: User
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 <TXT

1 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 <TXT

1 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.