Welcome Guest, Not a member yet? Register   Sign In
Why $CI =& get_instance(); in each function
#1

[eluser]TerryT[/eluser]
I have a library where I call this in the constructor:


Code:
class Mypdf extends TCPDF
function __construct()    {
  parent::__construct();  
    $CI =& get_instance();
    $CI->load->library('session');
    $CI->load->library('pdf');

I also have these methods:

Code:
public function newpdf($title, $subject, $report_name)
public function body_project_listing()

To access sessions in either of the functions, I have to call:

Code:
$CI =& get_instance();
    $CI->load->library('session');
    $CI->load->library('pdf');
[/code]

in each function. Can anyone let me know why I can't just call it in the parent::__construct()? Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB