account for missing/optional arguments in functions?

From: Date: Thu, 25 Oct 2001 22:57:33 +0000
Subject: account for missing/optional arguments in functions?
Groups: php.general 
Request: Send a blank email to php-general+get-72361@lists.php.net to get a copy of this message
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

« previous php.general (#72361) next »