Hooks in Codeigniter
问题 How can I call a hook for only a few controllers instead of all controllers in CodeIgniter? E.g.: I want to run the hook for only the admin section. How can I achieve this? 回答1: In the hook which you wish to run selectively, you can access the ci superobject using $this->ci =& get_instance(); . This acts as a pointer which can be used to access the CodeIgniter router to determine the class using $class = $this->ci->router->fetch_class(); . You can then check if $class matches a certain value.