The example in this article describes how thinkphp uses the template engine in CLI mode. Share to everyone for your reference. Specific as follows:
With respect to the CLI pattern and the template engine, the manual in 2.1 illustrates this:
The CLI mode does not use any template engine by default (can be called by itself in the action method);
But how to invoke, not mentioned in the manual. So he had plenty of hands.
Before describing how to call, it is simple to say what might be needed to use the module engine:
1. Use Dompdf to automatically generate PDF or HTML reports on scheduled tasks
2. Scheduling tasks to send HTML-type messages
3. Automatically generate static pages in the background
4. Other background operations on templates
<?php//This document is automatically generated for test run class Indexaction extends action{private $view; public Function index () { //import View Imp ORT (' Think.Template.TagLib '); Import (' Think.Template.ThinkTemplate '); Import (' Think.Core.View '); This document is automatically generated for test run only C (' Cache_path ', cache_path); $this->view = think::instance (' view '); $this->view->assign (' Rows ', Array (' title ' = ' Test ',)); $this->view->assign (' title ', ' This is a title '); $content = $this->view->fetch (' index/index.html '); Var_dump ($content); }}?>
More interested in thinkphp related content readers can view this site topic: "thinkphp Introductory Course" and "thinkphp Common methods Summary"
It is hoped that this article is helpful to the PHP program design based on thinkphp framework.