Thinkphp method for using the template engine in CLI mode _php instance

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. Specifically as follows:

For the CLI mode and template engine, the manuals in 2.1 illustrate this:

CLI mode does not use any template engine by default (it can be invoked on its own in the Operation method);

But how to call, not mentioned in the manual. So he began to have ample clothing.

Before describing how to call, simply say what might be needed to use the module engine:

1. Use Dompdf to automatically generate PDF or HTML reports on a scheduled task
2. Scheduled Tasks send HTML type of message
3. Automatically generate static pages in the background
4. Other background operations on templates

<?php
//This document is automatically generated, only for test run
class Indexaction extends Action
{
 private $view;
 Public Function Index () {
  //Imports View import
  (' Think.Template.TagLib ');
  Import (' Think.Template.ThinkTemplate ');
  Import (' Think.Core.View ');
  This document is automatically generated, only for test run
  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 the site topics: "thinkphp Introductory Course" and "thinkphp Common methods Summary"

I hope this article will help you with the PHP program design based on thinkphp framework.

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.