[PHP] method overloading in a class

2010-08-18 Thread Ashley Sheridan
Hi list, I know that some languages such as C++ can overload functions and methods by declaring the method again with a different number of arguments, and the compiler internally sorts things out, but I can't seem to find a similar way to do this with PHP. Basically, what I've got at the moment

Re: [PHP] method overloading in a class

2010-08-18 Thread chris h
Would something like this work for you? class foo { public function bar($arg1, $arg2, $arg3=null) { if (isset($arg3)){ { return $this-_bar3($arg1, $arg2, $arg3); } else { return $this-_bar2($arg1, $arg2); } } also you may want to look into the

Re: [PHP] method overloading in a class

2010-08-18 Thread Ashley Sheridan
On Wed, 2010-08-18 at 12:35 -0400, chris h wrote: Would something like this work for you? class foo { public function bar($arg1, $arg2, $arg3=null) { if (isset($arg3)){ { return $this-_bar3($arg1, $arg2, $arg3); } else { return

Re: [PHP] method overloading in a class

2010-08-18 Thread Adam Richardson
On Wed, Aug 18, 2010 at 12:23 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: Hi list, I know that some languages such as C++ can overload functions and methods by declaring the method again with a different number of arguments, and the compiler internally sorts things out, but I can't