function foo($arg1, $arg2="") // or you can replace the "" with array() { blah }
Jim ----- Original Message ----- From: "Kurt Lieber" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]