我正在尝试在twig库中添加codeigniter函数$this->session->flashdata()
。但我收到了以下错误:
Type: Error
Message: Call to a member function flashdata() on null
我在twig库的代码是:
$this->twig->addFunction(new Twig_SimpleFunction('flash_data', function($data){return $this->session->flashdata($data);}));
在我的twig文件中,我这样称呼:{{ flash_data('login_error') }}
答案 0 :(得分:1)
$this->twig->addFunction(new Twig_SimpleFunction('flash_data', function($data){
$obj =& get_instance();
return $obj->session->flashdata($data);
}));