The process of page output in thinkphp is to read the template file, and then to 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, then when the page output, We were unable to read the template file, and the 3.1 version added the function of content parsing output.
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 3.1 view classes and http://www.aliyun.com/zixun/aggregation/16339.html "> The action class has also made some 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 ', ' by ');
In short, with the Show method, you can put the template in the database, the template management and update is also more convenient.