Home > Backend Development > PHP Tutorial > Yii2 gets module name, controller name, method name

Yii2 gets module name, controller name, method name

WBOY
Release: 2016-07-29 09:04:47
Original
1264 people have browsed it

Yii2 Get module name, controller name, method name

in the view:

Module name $this->context->module->id

Controller name $this->context-> ;id

Method name $this->context->action->id

in the controller

Module name Yii::$app->controller->module->id;

Controller name Yii::$app->controller->id

Method name Yii::$app->controller->action->id;

or

Module name$ this->module->id;

Controller name $this->id;

Method name $this->action->id;

In the beforeAction method of the controller ( method receives $action parameter)

Module name $action->controller->module->id;

Controller name $action->controller->id;

Method name $action-> id;

The above introduces how Yii2 obtains the module name, controller name, and method name, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template