douwengzao5790 2018-09-03 18:32
浏览 49
已采纳

Codeigniter:Message:在null上调用成员函数行()

Codeigniter:

I am doing this in language/english/pages/about-me_lang.php:

<?php echo $this->lang->line('url_Contact')?>

and I am given this error:

Message: Call to a member function line() on null

so $this doesn't have lang...

What should I use to get lang line variable?

And how to know that is $this anyway? I mean in the whole thing (Codeigniter)

Thanks

Update 1:

enter image description here

it is here, in these files that nothing with $this-> will work, like $this->load or $this->lang.

What is $this here and how to get $this that I can load files there?

Update 2:

$this is applicable inside a class context.

So it means that a php file in views folder belongs to a class (is it from a controler class context?), but php file under language isn't, hm...

Update 3:

So, in view we have CI_Loader and based on this: https://www.codeigniter.com/user_guide/libraries/loader.html

is responsible for what it is responsible :)

...but, under the language folder, we have a different thing:

because when I try: $this->load->model('functions');

i get:

Message: Undefined property: CI_Lang::$load

Now, how with CI_Lang class to get that variable?

Update 4:

Found the solution, posted it as separate answer down below!

  • 写回答

2条回答 默认 最新

  • duanliu8998 2018-09-03 19:44
    关注

    To get a line of text from a language file, but INSIDE files that are under language folder this is the solution:

    <?php echo $this->line('url_Contact')?>
    

    because, the class context there is CI_Lang.

    Thanks Rinsad for mantioning class context.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作