我有几个常见的变量,我想用钩子设置.例如我有一个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');
}
Run Code Online (Sandbox Code Playgroud)
但是如何将生成的变量$ home_folder传递回控制器?
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;
}
Run Code Online (Sandbox Code Playgroud)
会这样做.
归档时间: |
|
查看次数: |
1848 次 |
最近记录: |