简体   繁体   English

调用库函数时发生未定义的属性错误

[英]Undefined property error when calling a library function

I have two controllers in user folder. 我的用户文件夹中有两个控制器。 One is user and othe one is profile. 一种是用户,另一种是个人资料。 And also have a library called category_detail in category folder. 并且在category文件夹中还有一个名为category_detail的库。 when I call $this->category_detail->get_category_detail(2); 当我调用$this->category_detail->get_category_detail(2); in user controller it works well. 在用户控制器中效果很好。 But when I do same call in profile controller it gives an error. 但是,当我在配置文件控制器中执行相同的调用时,会出现错误。 In both file I have loaded category_detail library in constructor. 在这两个文件中,我都在构造函数中加载了category_detail库。 error is follows. 错误如下。

Severity: Notice 严重程度:注意

Message: Undefined property: Profile::$category_detail 消息:未定义的属性:Profile :: $ category_detail

Filename: user/profile.php 文件名:user / profile.php

check this link 检查此链接

http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html

you have to put your library file in application/libraries folder 您必须将您的库文件放在application / libraries文件夹中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM