Re: Stupid question
| From: | Luis Mirabal | Date: | Wed, 17 Mar 2004 23:18:00 +0000 |
| Subject: | Re: Stupid question | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-180769@lists.php.net to get a copy of this message | ||
as Chris W. Parker noticed, there is a little mistake in the example above
posted by me, it says:
//Class function
function set() {
$sum = $this->a . $this->b . $this->c;
}
and it should say:
//Class function
function set() {
$this->sum = $this->a . $this->b . $this->c;
}
sorry :P
luis.
"Luis Mirabal" <mirabal@adinet.com.uy> escribió en el mensaje
news:20040317210203.96490.qmail@pb1.pair.com...
> when you are working with classes and objects in php, and you are coding
> inside a class, you must use the $this variable to access the members of
the
> class, for example:
>
> class test {
>
> //Class vars (something like properties)
> var $a;
> var $b;
> var $c;
> var $sum;
>
> //Class function (Constructor)
> function test() {
> $this->a = 'value for a';
> $this->b = 'value for b';
> $this->c = 'value for c';
> $this->set();
> }
>
> //Class function
> function set() {
> $sum = $this->a . $this->b . $this->c;
> }
>
> } //end class
>
> luis.