Global functions - 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: Global functions (/showthread.php?tid=33213) Pages:
1
2
|
Global functions - El Forum - 08-19-2010 [eluser]mabright[/eluser] OK. I tried this with error below. Code: A PHP Error was encountered Code: Code: class Location { Global functions - El Forum - 08-19-2010 [eluser]mddd[/eluser] If you use $CI in one method, it is not set in another method! You need to make a class property $CI and, in your methods, refer to it as $this->CI. Code: class Location Global functions - El Forum - 08-19-2010 [eluser]mabright[/eluser] Wow...how much I still do not know...That did the trick, thanks alot... Global functions - El Forum - 08-30-2010 [eluser]mabright[/eluser] I have this global variable working in my view but when I reference $data['variable_name'] in my controller or model, I get an undefined variable error. Global functions - El Forum - 08-30-2010 [eluser]cahva[/eluser] If you're sending $data to view: Code: $data['variable_name'] = 'Foo'; ..then you would reference it as $variable_name in the view. EDIT: misread sorry. You ofcourse have to send the $data to your lib or model. BTW, If you need some information in almost every page, you should concider MY_Controller technique where you extend from that. Or even better, take advantage of autoloading classes in PHP5 and use technique described here by Phil Sturgeon. |