Re: Constructors with multiple methods

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Damien wrote:
Hi all,

Say you may want to create an instance in multiple ways, such as creating
from scratch or loading from a database. Is something like this normal for
creating an instance?

I do this:

class Foo {
  function Foo($id=0)
  {
    if (is_int($id) && (int)$id > 0) {
      return $this->Load($id);
    }
    // set default variables.
  }
}

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux