![]() |
why pass reference to Codeigniter super object instead of copying it? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: why pass reference to Codeigniter super object instead of copying it? (/showthread.php?tid=51875) |
why pass reference to Codeigniter super object instead of copying it? - El Forum - 05-21-2012 [eluser]MikeW1911[/eluser] According the documentation, to use the native Codeigniter resources in a custom class I should pass a reference to the Codeigniter super object like so: Code: $CI =& get_instance(); My custom library seems to work by copying the super object instead of passing a reference. Is it simply more efficient to pass a reference to the CI super object rather than making a copy or are there other reasons to pass a reference to the super object? why pass reference to Codeigniter super object instead of copying it? - El Forum - 05-21-2012 [eluser]CroNiX[/eluser] Passing by reference allow you to access everything thats already loaded by CI. If you make a copy, you are copying everything that's loaded consuming 2x the resources. |