Class instantiation issue with CI 3.0.2 & PHP 5.6 |
I just upgraded an existing app to CI v3.02 & PHP v5.6. I'm running into a conflict when instantiating a class then accessing certain methods in $this var, the methods seem to be overwritten by the new class instance. Here is an example, imagine the first line is being called from some other class:
PHP Code: $upload = (new Post)->uploadImage($data); $this->config is returning the expected value I have in my config file. $this->upload is throwing the error "Undefined property: Post::$upload" which means it has overwritten the upload library in CodeIgniter. How can I avoid this from happening? A few notes:
I'd appreciate any help. Thank you.
Is CI_Controller an ancestor of that class? Controllers in CI are singletons, you're not supposed to instantiate more than one.
(10-20-2015, 01:39 AM)Narf Wrote: Is CI_Controller an ancestor of that class? Controllers in CI are singletons, you're not supposed to instantiate more than one. Yes, CI_Controller was an ancestor of the Post class. Thanks for pointing out that they're singletons. I corrected the issue by eliminating multiple calls to the controllers. |
Welcome Guest, Not a member yet? Register Sign In |