NYCPHP Meetup

NYPHP.org

[nycphp-talk] Method overloading

Kenneth Downs ken at secdat.com
Fri Dec 14 14:24:24 EST 2007


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


-- 
Kenneth Downs
Secure Data Software, Inc.
www.secdat.com    www.andromeda-project.org
631-689-7200   Fax: 631-689-0527
cell: 631-379-0010




More information about the talk mailing list