CodeIgniter:无法在函数内访问$ this
||
我正在使用CodeIgniter,我的视图之一很大,因此我将某些代码移到了同一文件中的函数中:
function html_stuff()
{
$posts = $this->db->query(\'select * from posts\');
}
当我运行此代码时,出现以下错误:
致命错误:不在时使用$ this
/somepath/view.php中的对象上下文
没有找到相关结果
已邀请:
1 个回复
磋判粗惊
或者用use3ѭ
请参阅:https://www.codeigniter.com/user_guide/general/creating_libraries.html