![]() |
Assigning variables to whole controller [Best Practice?] - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Assigning variables to whole controller [Best Practice?] (/showthread.php?tid=36544) |
Assigning variables to whole controller [Best Practice?] - El Forum - 12-05-2010 [eluser]Unknown[/eluser] I have a class that has multiple functions in it. There are some variables that I want to be referenced upon through-out the whole controller class. I have the following variables Code: $affid = $this->session->userdata('affid'); I want these variables with these values to be able to be called upon in other functions inside my controller class. I tried putting the above code in my constructor, but the variables cannot be referenced in any other functions within the class besides the constructor. Any suggestions on how I can make variables global to my class? Assigning variables to whole controller [Best Practice?] - El Forum - 12-05-2010 [eluser]techgnome[/eluser] Declare them publically in the class block... Code: class SomeClass extens CI_Example Does that help? -tg Assigning variables to whole controller [Best Practice?] - El Forum - 12-18-2010 [eluser]Bartolo![/eluser] It did for me... ;-) Thanks! |