![]() |
Class instantiation issue with CI 3.0.2 & PHP 5.6 - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17) +--- Thread: Class instantiation issue with CI 3.0.2 & PHP 5.6 (/showthread.php?tid=63323) |
Class instantiation issue with CI 3.0.2 & PHP 5.6 - sjefferson - 10-19-2015 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. RE: Class instantiation issue with CI 3.0.2 & PHP 5.6 - Narf - 10-20-2015 Is CI_Controller an ancestor of that class? Controllers in CI are singletons, you're not supposed to instantiate more than one. RE: Class instantiation issue with CI 3.0.2 & PHP 5.6 - sjefferson - 10-20-2015 (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. |