ThinkPHP3.1 the content analytic output of new characteristic _php example

Source: Internet
Author: User

The process of page output in previous versions of thinkphp is to read the template file, and then parse the template (also support the invocation of Third-party template engine parsing), but there are some cases where we do not define the template file, or save the template file in the database, so when the page output, We were unable to read the template file, and the ThinkPHP3.1 version added the function of content parsing output to this situation.

The built-in template engine is also perfected, and if the incoming template file does not exist, it is considered the incoming template parsing content, so the ThinkPHP3.1 version of the view class and the action class also makes some corresponding improvements.

The display method is used for template file render output, the Show method is used for the template content rendering output, and the Show method still supports the content parsing function , so we can use this in the controller:

$this->assign (' name ', ' thinkphp ');
$this->show (' hello,{$name}! ');

The results of the page output are:

hello,thinkphp!

You can also read the database by:

$content = M (' Data ')->where ($map)->getfield (' content ');
$this->show ($content);

For the contents of the $content variable, you can support the parsing of variables and tag libraries as well as template files, and you can also support template layout features.
The Show method can also specify the output encoding and type, for example:

$this->show ($content, ' utf-8 ', ' text/xml ');

In short, with the Show method, you can put the template in the database, for the template management and update is also more convenient.

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.