Bonjour Shane,
Le mercredi 11 septembre 2002 à 11:21:53, vous écriviez :
S> Martin, so if I write...
S> function myFunction($name, $phone, $zip=""){
S> echo $name.$phone.$zip
S> }
S> and $zip is NOT SET then $zip will = .
S> But if $zip IS SET then $zip will = whatever $zip's current value is, and will NOT
be changed to ?
S> Please advise.
S> Thanks Martin
S> -Original Message-
S> From: Martin Towell [mailto:[EMAIL PROTECTED]]
S> Sent: Tuesday, September 10, 2002 5:14 PM
S> To: Shane; [EMAIL PROTECTED]
S> Subject: RE: [PHP] Easy Function Question?
S> function myFunction($name, $phone, $zip=""){
S> echo $name.$phone.$zip
S> }
S> is the corrent format, but if you call it like this:
S> myFunction("name", "phone", null);
S> then $zip will equal null, not ""
S> something like this might help
S> function myFunction($name, $phone, $zip=""){
S> if (!$zip) $zip = "";
S> echo $name.$phone.$zip
S> }
S> HTH
S> Martin
Why don't you just try ? ;-)
S> -Original Message-
S> From: Shane [mailto:[EMAIL PROTECTED]]
S> Sent: Wednesday, September 11, 2002 10:14 AM
S> To: [EMAIL PROTECTED]
S> Subject: [PHP] Easy Function Question?
S> I have a need to call a function, where all the variables used might not be
S> set. Is there a way to have a variable in a function have a default setting
S> if the variable passed to the function is VOID?
S> EXAMPLE:
S> $name="me";
S> $phone="";
S> //$zip is VOID
S> function myFunction($name, $phone, $zip){
S> echo $name.$phone.$zip
S> }
S> can I write...?
S> function myFunction($name, $phone, $zip=""){
S> echo $name.$phone.$zip
S> }
S> and then $zip will have a value of if $zip is VOID for some reason...?
S> I thought it was something like this, but I keep batting ZERO and there is
S> no mention of this problem in the places I looked in the docs.
S> Can anyone throw me a bone?
S> Thanks gang!
S> -NorthBayShane
--
Cordialement,
Hajmailto:[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php