Class attributes

Im am setting some class attributes as empty array’s with a Class constructor. Later in a Method i insert a value into one of these attributes i.e. $this->attribute1 = array(‘item_01’). Then in the Method i check if this attribute has a value and if it does the Method returns true, else it returns false.

If i check the attribute before i run this Method and after i have run this Method it is empty. Is this a Method scope thing that the attribute only has the value assigned to it when referenced from inside the method that has set it i.e. $this->attribute1. My questions really boils down to why the Class attribute is still empty if i reference it separately even though a Method has been called that assignes it a value.

Thanks!

Hi Banana Man,

Would it be possible to post the code of the class? It would make it easier to see what’s going on (although it could just be that I’ve not had enough coffee this morning!)

No, you are not alone. I really think I need to see the class and the implementation of that class to wrap my head around it too.

Ahhh, i had an error in my code. Things are now working as a expected. Sorry for the confusing explanation!