【问题标题】:Can I access controller action from the header.php view in Codeigniter?我可以从 Codeigniter 中的 header.php 视图访问控制器操作吗?
【发布时间】:2016-03-07 20:23:14
【问题描述】:

我只想从 CodeIgniter 中的 header.php 文件中访问某个类的特定方法。我尝试创建一个助手。但它只是破坏了我所有的页面内容加载。 它说我不能在 header.php 中使用$this。 提前致谢。

【问题讨论】:

  • 您应该包含您的代码以供参考 =]

标签: codeigniter methods header helper


【解决方案1】:

您可以这样做,而不是使用$this

$ci = &get_instance();

并使用$ci 就像$this 例如$ci->model->function();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-05
    相关资源
    最近更新 更多