NYCPHP Meetup

NYPHP.org

[nycphp-talk] multiple constructors

Phillip Powell phillip.powell at adnet-sys.com
Wed Sep 29 18:56:51 EDT 2004


Matthew Terenzio wrote:

> Can I have multiple constructors, a certain one being called depending 
> on the number or type of parameters passed to the class upon 
> instantiation.
>
> PHP 5 - if so, any gotchas that one might expect from similar OOP 
> languages that won't work here.
>
> Matt


Unfortunately no, but then again, most would argue that multiple 
constructors are a bad thing.  Unlike in Java, where parameters are not 
allowed to be set as optional, PHP allows for this at the expense of 
uniquely-named constructors.

Thus, in Java you have multiple constructors because you have to, in PHP 
you can't have multiple constructors because you don't ever have to.

Phil

>
> _______________________________________________
> New York PHP Talk
> Supporting AMP Technology (Apache/MySQL/PHP)
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.newyorkphp.org
>


-- 
---------------------------------------------------------------------------------
Phil Powell
Multimedia Programmer
BPX Technologies, Inc.
#: (703) 709-7218 x107 
Fax: (703) 709-7219

	




More information about the talk mailing list