CodeIgniter: How to get Controller, Action, URL information

前端 未结 11 1241
死守一世寂寞
死守一世寂寞 2020-12-07 09:21

I have these URLs:

  • http://backend.domain.com/system/setting/edit/12
  • http://backend.domain.com/product/edit/1

How to get controller nam

11条回答
  •  盖世英雄少女心
    2020-12-07 10:04

    controller class is not working any functions.

    so I recommend to you use the following scripts

    global $argv;
    
    if(is_array($argv)){
        $action = $argv[1];
        $method = $argv[2];
    }else{
        $request_uri = $_SERVER['REQUEST_URI'];
        $pattern = "/.*?\/index\.php\/(.*?)\/(.*?)$/";
        preg_match($pattern, $request_uri, $params);
        $action = $params[1];
        $method = $params[2];
    }
    

提交回复
热议问题