Description of three ways to render the thinkPHP5 framework template, thinkphp5 framework

Source: Internet
Author: User

Description of three ways to render the thinkPHP5 framework template, thinkphp5 framework

This article describes three thinkPHP5 Framework rendering templates. We will share this with you for your reference. The details are as follows:

By default, the Controller outputs all in the return mode, without any manual output. The system automatically outputs the rendering content.

Rendering templates in the Controller

Namespace app \ index \ controller; use think \ view; class Index {public function index () {$ view = new view (); return $ view-> fetch ('index ');}}

Directly use the view assistant function rendering Template

Namespace app \ index \ controller; class Index {public function index () {return view ('index ');}}

Inherit the think \ Controller class

If the think \ Controller class is inherited, you can directly call the methods of the think \ View and think \ Request classes. Example:

Namespace app \ index \ controller; use think \ Controller; class Index extends Controller {public function index () {$ this-> assign ('domain ', $ this-> request-> url (true); return $ this-> fetch ('index ');}}

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.