declaring class level variables in codeigniter |
[eluser]Syed Wasti[/eluser]
Hi, I am new to CI and what I want to do is to have a class level variable (which e.g is an array). But it seems like CI, despite all high bragging, doesn't support this feature. Nothing has been mentioned in the user guide about it. There is a heading called private functions and variables but the text has been seemingly kept silent regarding variables. I want to have something like --> Code: class OrderStats extends CI_Controller { I keep getting an error messag that $arr_CoreCountry is an undefined variable. Where do I define it? Am I declaring it at a wrong place? Expect a quick response as half of my day has been wasted just because of this s*** from codeigniter.
[eluser]Seb[/eluser]
Well this has nothing to do with codeigniter, but it is just basic PHP coding: http://www.php.net/manual/en/language.oop5.basic.php You should type : Code: foreach ($this->arr_CoreCountry as $key => $value) instead of Code: foreach ($arr_CoreCountry as $key => $value)
[eluser]Syed Wasti[/eluser]
Well yes, it really is a question of basics. When you write $this, it generates an error message that $this can't be used when not in an object's context.
|
Welcome Guest, Not a member yet? Register Sign In |