thinkphp5獲取控制器名、模型名、方法名的代碼
thinkphp5獲取控制器名、模型名、方法名和thinkphp3.2已經不一樣了,使用thinkphp3.2的那種方法已經獲取不到了,thinkphp5獲取這三個的方法如下。
$request= \think\Request::instance();
dump($request->controller()); //獲取控制器名
dump($request->module()); //獲取模型名
dump($request->action()); //獲取方法名
使用以上代碼獲取的話,控制器需要
$request= \think\Request::instance();
dump($request->controller()); //獲取控制器名
dump($request->module()); //獲取模型名
dump($request->action()); //獲取方法名
使用以上代碼獲取的話,控制器需要
class 類名 extends \think\Controller
{
……
}
中國· 上海

添加微信咨詢
CopyRight?2009-2019 上海谷谷網絡科技有限公司 All Rights Reserved. 滬ICP備11022482號-8
- top
- 在線咨詢
-
添加微信咨詢