3

我有几个想要使用钩子设置的公共变量。例如,我有一个 post_controller_constructor 钩子,在其中我想执行一些逻辑来设置用户主文件夹:

public function post_controller_constructor() {             
  $home_folder = isset($_SESSION['hf']) ? $_SESSION['hf'] : NULL;

  // Check whether the homefolder value has been set            
  $home_folder = isset($_SESSION['hf']) ? base_url($_SESSION['hf']) : base_url('default');
}

但是如何将结果变量 $home_folder 传递回我的控制器?

4

1 回答 1

5
public function post_controller_constructor() {             
  $home_folder = isset($_SESSION['hf']) ? $_SESSION['hf'] : NULL;

  // Check whether the homefolder value has been set            
  $home_folder = isset($_SESSION['hf']) ? base_url($_SESSION['hf']) : base_url('default');

  $CI =& get_instance();

  $CI->home_folder = $home_folder;

}

会做的。

于 2012-06-20T21:09:37.900 回答