NYCPHP Meetup

NYPHP.org

[nycphp-talk] multiple constructors

Matthew Terenzio webmaster at localnotion.com
Wed Sep 29 21:51:08 EDT 2004


> 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.

So,  put the max number of parameters that could be passed in the  
constructor and just pass arg1, arg2 to the max upon instantiation,  
depending on the situation?



On Sep 29, 2004, at 6:56 PM, Phillip Powell wrote:

> 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.
>
>
>
> 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
>
> 	
>
> _______________________________________________
> New York PHP Talk
> Supporting AMP Technology (Apache/MySQL/PHP)
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.newyorkphp.org




More information about the talk mailing list