* Daniel Schierbeck <[EMAIL PROTECTED]>:
> Giles Roadnight wrote:
> > If I defined a function with 4 parameters but only pass 3 I get an
> > error. Is there anyway around this?
> >
> > I want to be able to set the missing parameter to a default value if it
> > is not passed which works ok but How do I get rid of the error message?
>
> If you want an argument to be optional and still be able to check
> whether or not it's been set, you can use NULL as the default value:
>
> function foobar ($a, $b, $c = null)
> {
> if (isset($c)) {
> echo 'The third argument was set';
> }
> }
That check should be for 'is_null($c)' as the default value of $c will
be null, and it will be always set, even if not sent.
--
Matthew Weier O'Phinney | mailto:[EMAIL PROTECTED]
Webmaster and IT Specialist | http://www.garden.org
National Gardening Association | http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php