ThinkPHP method for using the template engine in Cli mode _ php instance

Source: Internet
Author: User
This article mainly introduces ThinkPHP's method of using the template engine in Cli mode. The example analyzes ThinkPHP's technique of operating the template based on Cli mode, which has some reference value, for more information about how ThinkPHP uses the template engine in Cli mode, see the following example. Share it with you for your reference. The details are as follows:

The manual in section 2.1 describes the Cli mode and template engine as follows:

By default, no template engine is used in Cli mode (you can call it in the operation method );

But how to call it is not mentioned in the manual. As a result, you need to improve yourself.

Before introducing how to call the function, let's briefly talk about what situations may require the module engine:

1. Use dompdf to automatically generate PDF or HTML reports in scheduled tasks
2. send HTML-type emails to scheduled tasks
3. automatically generate static pages in the background
4. Other background operations on the template

<? Php // This document is automatically generated. It is only for testing and running class IndexAction extends Action {private $ view; public function index () {// import View import ('Think. template. tagLib '); import ('Think. template. thinktemplate'); import ('Think. core. view '); // this document is automatically generated and is only for testing and running 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) ;}}?>

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.