Anyway to access a class variable without using a return function?
| From: | Terence | Date: | Mon, 08 Mar 2004 05:42:30 +0000 |
| Subject: | Anyway to access a class variable without using a return function? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-180406@lists.php.net to get a copy of this message | ||
Hi List,
I have a class with a constructor that sets the variables and I currently
use functions to return each one. When using alot of variables in the
constructor i tend to have many return functions. Is there a way to access
the constructor variables without using a return function?
This is how I do it:
class MyClass {
function MyClass {
$this->var1="1";
$this->var2="2";
}
function GetVar1() {
return $this->var1;
}
function GetVar2() {
return $this->var2;
}
}
Thanks