thinkphp5 获取当前模块、控制器、操作

因为ThinkPHP5.1的手册上没找到也不知道是不是没写,在网上送到了记一下。
首先,命名空间导入 Request 类

use think\facade\Request;

然后再你需要的地方使用下列办法获取 模块、控制器、操作的名字即可

$moduleName = Request::module();
$controllerName = Request::controller();
$actionName = Request::action();

猜你喜欢

转载自blog.csdn.net/weixin_45956258/article/details/103352642