User class not found |
Hello,
in the folder *application/libraries* I installed a script "Utilities.php", with a class "Utilities". Instancing the class is no problem, also reflection displays all methods. but when I pass the object to the constructor of another class, I get the strange error Severity: Error Message: Class 'CI_Utilities' not found Filename: core/Common.php Line Number: 196 Why does CI create a class CI_Utilities from a user class? What is wrong here? thanx for your help, Helmut
How do you load this class in your code? with load->library('Utilities') or autoload ?
1 advice - to prevent duplication of CI Class names try adding prefix or suffix to your class : Utilities_library.. Best VPS Hosting : Digital Ocean
(11-02-2015, 08:02 AM)sv3tli0 Wrote: 1 advice - to prevent duplication of CI Class names try adding prefix or suffix to your class : Utilities_library.. This should only be done if you want to extend native CI-Libraries. https://ellislab.com/codeigniter/user-gu...aries.html Having looked into the sourcecode of Common.php, I have the impression that there is a bug.
How and to which class are you passing the utilities or user object?
Did a quick test with two libraries. One I called Utilities and the second one Test. I then did this: PHP Code: $this->load->library('Utilities'); Got 0 errors with this. So Utilities is not a reserved name within CI nore does CI change it in anyway that I chould see. (11-04-2015, 09:14 AM)Martin7483 Wrote: How and to which class are you passing the utilities or user object? Thanks,now I see that the problem is in the instanciation of the other class (Test in your example), which I did not perform correctly. But now after the commands $this->load->library('Test', array($this->utilities)); //here no error occurs -- $vars = get_object_vars($this->Test); var_dump($vars); I get the error Message: Undefined property: Test::$Test and Message: get_object_vars() expects parameter 1 to be object, null given (11-05-2015, 04:30 AM)helmut Wrote:(11-04-2015, 09:14 AM)Martin7483 Wrote: How and to which class are you passing the utilities or user object? As far as I know, you should use $this->test (in lower case) Also get_object_vars and var_dump should be called outside the Test class.
(11-05-2015, 04:48 AM)Martin7483 Wrote:(11-05-2015, 04:37 AM)pdthinh Wrote: As far as I know, you should use $this->test (in lower case) Unfortunately the error occurs in either version, lower AND upper case
|
Welcome Guest, Not a member yet? Register Sign In |