Re: simple question

From: Date: Tue, 26 Jun 2001 21:40:38 +0000
Subject: Re: simple question
References: 1  Groups: php.gtk 
Request: Send a blank email to php-gtk+get-1978@lists.php.net to get a copy of this message
David, Try this: class example { var $i; function example($x = 0) { $this->i = $x; } function plus() { $this->i++; } function minus() { $this->i--; } } The reason nothing was incrementing/de-incrementing for you was because you weren't using the $this-> notation to reference the $i variable in your functions to the $i you created with the var $i statement. The changes in the example() constructor will allow you to set the start value of $i with your class instantiation(sp?) call. eg: $obj = &new example(5); $obj = &new example(2); etc. HTH! Cheers, Geoff A. Virgo http://www.mithril.ca/ ------------------------------------------------------------------------------------------------------------------------ Do not meddle in the affairs of programmers, for they are subtle and quick to anger.

« previous php.gtk (#1978) next »