Function overloading, maybe - SOLVED

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ReverendDexter
Forum Contributor
Posts: 193
Joined: Tue May 29, 2007 1:26 pm
Location: Chico, CA

Function overloading, maybe - SOLVED

Post 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
Last edited by ReverendDexter on Mon Jun 25, 2007 6:03 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
Gente
Forum Contributor
Posts: 252
Joined: Wed Jun 13, 2007 9:43 am
Location: Ukraine, Kharkov
Contact:

Post by Gente »

User avatar
ReverendDexter
Forum Contributor
Posts: 193
Joined: Tue May 29, 2007 1:26 pm
Location: Chico, CA

Post by ReverendDexter »

Still learning to think PHP style...

Thanks!
Post Reply