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 ');}}