CI獲取控制器名和方法名
第一種方法:
即使有__CLASS__,__FUNCTION__魔術變量,但是在父類控制器,或者在model中,只能獲取當前類的類名和方法名。
第二種方法:
$this->uri->segment(3, 0);
這種是通過URL來獲取,萬一url路由被自定義了,這個方法又不太優雅。
第三種種方法:(完美)
$con = $this->router->fetch_class();//獲取控制器名
$func = $this->router->fetch_method();//獲取方法名
$dir = $this->router->fetch_directory();//獲取路徑
這是框架自帶的方法,官方文檔沒有介紹,深入挖掘框架得知