Page 1 of 1

OOP question

Posted: Tue Oct 28, 2003 4:56 am
by Fredix
Hi,
just a little thing:

You declare variables in a class like

var $myvar;

and access them like $this->myvar.

Now I've seen someone using a variable in a function (method) of a class without $this->.

Is this generally wrong, or is it allowed when you use that variable only inside that function?

Posted: Tue Oct 28, 2003 5:14 am
by twigletmac
If you're only going to use that variable within that method then you don't need to use $this->. Not all variables will need to be accessible globally within the class.

Mac

Posted: Tue Oct 28, 2003 5:16 am
by Fredix
exactly what I wanted!

Thank you very much!