Re: account for missing/optional arguments in functions?
| From: | Jim Lucas | Date: | Thu, 25 Oct 2001 22:55:37 +0000 |
| Subject: | Re: account for missing/optional arguments in functions? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-72364@lists.php.net to get a copy of this message | ||
function foo($arg1, $arg2="") // or you can replace the "" with array()
{
blah
}
Jim
----- Original Message -----
From: "Kurt Lieber" <php@kirpatrick.com>
To: <php-general@lists.php.net>
Sent: Thursday, October 25, 2001 3:57 PM
Subject: [PHP] account for missing/optional arguments in functions?
> Is it possible to account/trap missing arguments in functions?
>
> For instance, say I have a function foo:
>
> function foo($arg1,$arg2) { blah }
>
> If someone calls that function as:
>
> foo($arg1);
>
> Can I somehow code around the fact that $arg2 is missing? I've tried:
>
> function foo($arg1,$arg2) {
> if (!isset($arg2) { $arg2=0 }
> }
>
> But that doesn't work. However, that's the sort of functionality I'm
looking
> for -- is there a way to do it?
>
> Thanks.
>
> --kurt
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>