Cant I declare global varirable in controller? - 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: Cant I declare global varirable in controller? (/showthread.php?tid=7479) |
Cant I declare global varirable in controller? - El Forum - 04-10-2008 [eluser]geshan[/eluser] The following code shows error: Code: class Testlibc extends Controller{ How can I declare global variable in a contoller? Cant I declare global varirable in controller? - El Forum - 04-10-2008 [eluser]xwero[/eluser] in php4 you need to put var before the variable, in php5 you can control the scope of the variable with public, protected or private. Or var for php4 compatibility. Cant I declare global varirable in controller? - El Forum - 06-19-2008 [eluser]srajibtechno[/eluser] hello CI experts.. I am using global variable in my menu_model.php script... I already created two function and one constructor in my model.. But i can not fetch value from my global variable in my 2nd function named-sub_menu_getall().i need the query variable's value...in my 2nd function... how can i do this?? i am looking forward to hear from u... my code is given below.... Code: <?php Cant I declare global varirable in controller? - El Forum - 06-19-2008 [eluser]mglinski[/eluser] Drop Global Variables for CI. COmpletly. If you want a way to permiate variables throughout CI make a library that autoloads variables to a class variable. Then you access it like this: Code: $this->LIBRARY_NAME->config['VARIABLE_NAME']; Cant I declare global varirable in controller? - El Forum - 06-19-2008 [eluser]mglinski[/eluser] Oh and to access class functions and variables in-class you need a $this-> in front of what you are trying to access. EG Code: class Testlibc extends Controller |