|
Posted by Sanders Kaufman on 07/25/07 17:47
Toby A Inkster wrote:
> Sanders Kaufman wrote:
>
>> I'm noticing that the constructor is a "reset" switch - just like the
>> one on the front of my computer. Calling it seems to just dump all of
>> the old values, free up all of the old resources, and return the object
>> to a pristine state.
>
> Yes, you can do this, but it's a bit of a hack. Better to use something
> like:
>
> class Foobar
> {
> public $var1;
> public $var2;
>
> public function __construct ($foo, $bar)
> {
> $this->reset($foo, $bar);
> // Now maybe do some other stuff
> }
>
> public function reset ($foo, $bar)
> {
> $this->var1 = $foo;
> $this->var2 = $bar;
> }
> }
That is most certainly how I will do it in PHP5 - if it turns out that
the project is worth it's while.
Navigation:
[Reply to this message]
|