The following is the thinkphp framework tutorial column to introduce to you the differences between the view and fetch methods in the TP5 controller. I hope it will be helpful to friends in need!
TP5 The difference between the view and fetch methods in the controller
In the controller, the two methods are similar and different
In the controller, the three rendering methods of the template have different configuration displays.
//不继承controller $view = new view(); return $view->fetch('index/demo');
//不继承controller return view('index/demo');
//继承controller return $this->fetch('index/demo');
The latter two can output public configuration, tpl_replace_string, such as __CSS__, the path can be output in the template, the first type, the __CSS__ string can be output directly in the template
In the project, Try to use the latter two
writing methods, or inherit controller, this->fetch
or use the view method
new view();
but this cannot be read For the public configuration file, you need to set the parameters yourself. After instantiating the object, pass the parameters in, for example, write
The above is the detailed content of Difference: view and fetch methods in TP5 controller. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment