Possible Duplicate:
How do you create optional arguments in php?
I built a function with 1 argument. That function is called numerous places on many, many pages on my site. I just decided that I need another parameter for this function.
In order to avoid “Warning: Missing argument” errors, is there any way to add a second argument with a bit of logic that tests the presence of a second argument in the calling command?
I do not want to go back through my entire website and try to catch and update every function call merely to throw a null value on it in order to void the error messages.
Thanks.
You can specify a default value for your arguments:
$optional_arg2 = NULLspecifies that if not given when the function is called,$optional_arg2will beNULL. The default value of an argument can be a scalar value (string, number or boolean), an array, orNULL, but it cannot be a variable, class member or function call.