Page 1 of 1

Function overloading, maybe - SOLVED

Posted: Mon Jun 25, 2007 4:42 pm
by ReverendDexter
What I'd like to do is overload a function, but I'm not really sure what the PHPanese is for doing this. If I have a function foo($whatever), what is the proper way to make the function accept being called as foo($whatever) *and* foo($whatever, $parameter)?

I'm hoping there's another thread I can just be pointed to, but all I was finding was saying that PHP doesn't really do overloading. Am I trying to force a C++ concept onto a language that doesn't want it?

-Dex

Posted: Mon Jun 25, 2007 4:48 pm
by feyd
PHP doesn't support overloading in that sense since it doesn't care how many parameters you send to a function, nor their type (unless you're using type hinting.)

Use default values.

Posted: Mon Jun 25, 2007 4:50 pm
by Gente

Posted: Mon Jun 25, 2007 6:02 pm
by ReverendDexter
Still learning to think PHP style...

Thanks!