I am working on hook file, i am using pre_controller
function of hook, but when i tried to use base_url()
function in it, it is not working for me, it give me this error Call to undefined function base_url()
, can anyone please help me to resolve this error ? here i have added my whole function
$hook['pre_controller'] = function()
{
$this->CI = get_instance();
$ci =& get_instance();
$router =& load_class('Router', 'core','uri','url');
$controller_name = $router->fetch_class();
$action_name = $router->fetch_method();
$segement = $router->uri->segment(2);
echo base_url(); die;
try {
$rc = new ReflectionClass($controller_name);
} catch (Exception $ex) {
if($segement == "") {
echo base_url(); die;
//header("Location:".$controller_name.'/overview');
//redirect($controller_name.'/overview');
//exit;
}
}
};