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

Yii2 gets module name, controller name, method name

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-29 09:04:471303browse

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.

Statement:
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