smerny Posted November 23, 2009 Share Posted November 23, 2009 been awhile since I did java, but I seem to remember being able to name functions the same thing with different number of parameters... I tried this with php but it says I can not redeclare function... I suppose I could use optional parameters and just use conditional statements based on whether the parameters is the default value? would be helpful or example if you want some statistics functions that will work with both known values entered or a list of numbers (in which case it would have to do more calculations to determine the values) is this common practice? or is there a different way of doing it? Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted November 23, 2009 Share Posted November 23, 2009 PHP doesn't offer function overloading. You have to: + Use default parameters (if they'll work in your case) + Use differing function names (as if you were programming in C) + Use unnamed and variable arguments (which will render your code difficult to use) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.