扫码关注官方订阅号
tp5没有CONTROLLER_NAME了,怎么获取CONTROLLER名称
认证0级讲师
public function test(Request $request) { dump($request->controller()); }
多看源码
/** * 设置或者获取当前的模块名 * @access public * @param string $module 模块名 * @return string|Request */ public function module($module = null) { if (!is_null($module)) { $this->module = $module; return $this; } else { return $this->module ?: ''; } } /** * 设置或者获取当前的控制器名 * @access public * @param string $controller 控制器名 * @return string|Request */ public function controller($controller = null) { if (!is_null($controller)) { $this->controller = $controller; return $this; } else { return $this->controller ?: ''; } } /** * 设置或者获取当前的操作名 * @access public * @param string $action 操作名 * @return string|Request */ public function action($action = null) { if (!is_null($action)) { $this->action = $action; return $this; } else { return $this->action ?: ''; } }
好像没有了,,那就自己获取呗。。。
使用__CLASS__试试,还有获取方法的, METHOD__, __FUNCTION 不过要截取。。。
$request = \think\Request::instance(); echo $request->controller();exit;
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
多看源码
好像没有了,,那就自己获取呗。。。
使用__CLASS__试试,还有获取方法的, METHOD__, __FUNCTION 不过要截取。。。