Don't forget: if a function has multiple arguments the optional ones must be to the RIGHT of the required ones:
function testing123($one, $two="2", $three="3") // Good function testing123($one="1", $two, $three="3") // Bad function testing123($one="1", $two="2", $three) // Bad Mike Frazer "Chris Bailey" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > It could be, but then you would have two spaces in between the 2nd and 3rd > "blah", instead of just the one space. But, depending on your actual > application, this may work out. > > -----Original Message----- > From: DL Neil [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, October 24, 2001 10:41 AM > To: Arpad Tamas; Richard S. Crawford; sunny AT wde; php > Subject: Re: [PHP] how do i give optional arguments to functions?? > > > > On Wednesday 24 October 2001 19:14, Richard S. Crawford wrote: > > > > The default value for $image parameter was missing: > > > > > function top ($image="defaultvalue") { > > > if ($image=="defaultvalue") echo "blah blah blah"; > > > else echo "blah blah $image blah"; > > > } > > If the default value can be set to an empty string can the if statement then > be removed? > > function top ($image="") > { > echo "blah blah $image blah"; > } > > - watch those spaces (if they're present in live data)! > =dn > > > > -- > 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]