CodeIgniter Forums
how to access variable from a file - 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: how to access variable from a file (/showthread.php?tid=22230)



how to access variable from a file - El Forum - 09-02-2009

[eluser]ranjitbd[/eluser]
Code:
access variable and method

// we can load a library by following code

    $this->load->library('encrypt');

// suppose $abc is a variable and xyz() is a method exist in eccrypt file
// we can access the method by following code

    $this->encrypt->xyz();

// how can i access the variable $abc from encrypt file.and imagine that $abc is not
//inside the xyz() method

//then what will be the code



how to access variable from a file - El Forum - 09-02-2009

[eluser]umefarooq[/eluser]
you can access same as you are accessing library function

$this->encrypt->abc = $def;

you have to define you variable in you library class as public you can access any where in you application


how to access variable from a file - El Forum - 09-25-2009

[eluser]ranjitbd[/eluser]
[quote author="umefarooq" date="1251892066"]you can access same as you are accessing library function

$this->encrypt->abc = $def;

you have to define you variable in you library class as public you can access any where in you application[/quote]
Code:
//where you got the $def?