You are here: Re: Constructor as a "Reset" Button « PHP Programming Language « IT news, forums, messages
Re: Constructor as a "Reset" Button

Posted by Toby A Inkster on 07/25/07 08:42

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;
}
}

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 34 days, 12:16.]

Cryptography Challenge
http://tobyinkster.co.uk/blog/2007/07/24/crypto-challenge/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация