|
Posted by Oli Filth on 09/16/05 20:37
matt said the following on 16/09/2005 18:10:
> I made function that inputs 3 variables and outputs 1. I modified it to
> accept 4 variables. Most of the time, it will use the old method of 3
> variable input, but occasionally it will need that 4th var. is there a way
> to leave the code that calls the function in place, and add the ability to
> use a function w/ 4 variables? right now, it gives me a warning that the
> variable is not sent. I'd like to shy away from suppressing warnings. I'm
> using php 4.3
>
function foo($a, $b, $c, $d = DEFAULT_VALUE)
{
}
where DEFAULT_VALUE is whatever you want the value of $d to be when
foo() is called with only 3 arguments.
Now, calling:
foo(1, 2, 3);
is the same as calling:
foo(1, 2, 3, DEFAULT_VALUE);
--
Oli
[Back to original message]
|