Home >PHP Framework >ThinkPHP >Difference: view and fetch methods in TP5 controller
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!