[nycphp-talk] Method overloading
Ben Sgro
ben at projectskyline.com
Fri Dec 14 14:27:16 EST 2007
Yup,
I figured I'd go down that path. It just adds extra logic, because in one
case the 1st arg is an array, in the other its a bunch of strings.
Ok, so you the answer is "no", you can't do method overloading in php?
- Ben
Kenneth Downs wrote:
> Ben Sgro wrote:
>> Hello,
>>
>> Reading a java book on OOP, I wanted to do this in php:
>>
>> class foo
>> {
>> public function bar($string){...}
>> public function bar($string, $int, $array) {...}
>> }
>>
>>
>> It should provide different "signatures" and allow method overloading...
>> Why not in php?
>
> I can't answer the "why", but you can get to the same place by
> providing default values:
>
> class foo {
> public function bar ($string,$int=0,$array=array()) { ... }
> }
>
>>
>> Is that not built in?
>>
>> - Ben
>> _______________________________________________
>> New York PHP Community Talk Mailing List
>> http://lists.nyphp.org/mailman/listinfo/talk
>>
>> NYPHPCon 2006 Presentations Online
>> http://www.nyphpcon.com
>>
>> Show Your Participation in New York PHP
>> http://www.nyphp.org/show_participation.php
>
>
More information about the talk
mailing list