CodeIgniter Forums
CI instance in external class - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: CI instance in external class (/showthread.php?tid=32273)



CI instance in external class - El Forum - 07-18-2010

[eluser]Flynn[/eluser]
Hi guys, is it possible to load CodeIgniter object (get_instance() in libraries/helpers) in external php class.
For some reasons, i can't make library/helper out of one php class, but i need some variables from Framework in this class (no, i can't send variables there - this class is loaded before CI).

Thanks.


CI instance in external class - El Forum - 07-18-2010

[eluser]Buso[/eluser]
try this:
Code:
ob_start();
include('index.php');
ob_end_clean();
$CI =& get_instance();



CI instance in external class - El Forum - 07-19-2010

[eluser]Flynn[/eluser]
Thanks a lot, Buso. That code works, unfortunately, i decided to rework class to integrate it with CI without includes. Anyway, i hope some people will find it helpful.
Thanks again.