thinkphp _php instance of a method using the template engine in CLI mode

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

  • Related Article

    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.