RE: [PHP] Easy Function Question?

2002-09-10 Thread Martin Towell

function myFunction($name, $phone, $zip=){
 echo $name.$phone.$zip
}

is the corrent format, but if you call it like this:

myFunction(name, phone, null);

then $zip will equal null, not 
something like this might help

function myFunction($name, $phone, $zip=){
 if (!$zip)  $zip = ;
 echo $name.$phone.$zip
}

HTH
Martin

-Original Message-
From: Shane [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 11, 2002 10:14 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Easy Function Question?


I have a need to call a function, where all the variables used might not be
set. Is there a way to have a variable in a function have a default setting
if the variable passed to the function is VOID?

EXAMPLE:

$name=me;
$phone=;
//$zip is VOID

function myFunction($name, $phone, $zip){
 echo $name.$phone.$zip
}

can I write...?

function myFunction($name, $phone, $zip=){
 echo $name.$phone.$zip
}

and then $zip will have a value of  if $zip is VOID for some reason...?

I thought it was something like this, but I keep batting ZERO and there is
no mention of this problem in the places I looked in the docs.

Can anyone throw me a bone?
Thanks gang!

-NorthBayShane

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Easy Function Question?

2002-09-10 Thread Shane

Martin, so if I write...

function myFunction($name, $phone, $zip=){
 echo $name.$phone.$zip
}

and $zip is NOT SET then $zip will = .
But if $zip IS SET then $zip will = whatever $zip's current value is, and will NOT be 
changed to ?

Please advise.
Thanks Martin

-Original Message-
From: Martin Towell [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 10, 2002 5:14 PM
To: Shane; [EMAIL PROTECTED]
Subject: RE: [PHP] Easy Function Question?


function myFunction($name, $phone, $zip=){
 echo $name.$phone.$zip
}

is the corrent format, but if you call it like this:

myFunction(name, phone, null);

then $zip will equal null, not 
something like this might help

function myFunction($name, $phone, $zip=){
 if (!$zip)  $zip = ;
 echo $name.$phone.$zip
}

HTH
Martin

-Original Message-
From: Shane [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 11, 2002 10:14 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Easy Function Question?


I have a need to call a function, where all the variables used might not be
set. Is there a way to have a variable in a function have a default setting
if the variable passed to the function is VOID?

EXAMPLE:

$name=me;
$phone=;
//$zip is VOID

function myFunction($name, $phone, $zip){
 echo $name.$phone.$zip
}

can I write...?

function myFunction($name, $phone, $zip=){
 echo $name.$phone.$zip
}

and then $zip will have a value of  if $zip is VOID for some reason...?

I thought it was something like this, but I keep batting ZERO and there is
no mention of this problem in the places I looked in the docs.

Can anyone throw me a bone?
Thanks gang!

-NorthBayShane

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Easy Function Question?

2002-09-10 Thread Martin Towell

if you pass a third parameter, then $zip will equal that parameter
If you only pass two parameters, then $zip will equal 

eg1. myFunction($var1, $var2);
  $zip will = 

eg2. myFunction($var1, $var2, $var3);
  $zip will = $var3, no matter what $var3 contains
  $var3 could be null, , or foobar, it doesn't matter, $zip will = $var3

Martin

-Original Message-
From: Shane [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 11, 2002 10:22 AM
To: Martin Towell; [EMAIL PROTECTED]
Subject: RE: [PHP] Easy Function Question?


Martin, so if I write...

function myFunction($name, $phone, $zip=){
 echo $name.$phone.$zip
}

and $zip is NOT SET then $zip will = .
But if $zip IS SET then $zip will = whatever $zip's current value is, and
will NOT be changed to ?

Please advise.
Thanks Martin

-Original Message-
From: Martin Towell [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 10, 2002 5:14 PM
To: Shane; [EMAIL PROTECTED]
Subject: RE: [PHP] Easy Function Question?


function myFunction($name, $phone, $zip=){
 echo $name.$phone.$zip
}

is the corrent format, but if you call it like this:

myFunction(name, phone, null);

then $zip will equal null, not 
something like this might help

function myFunction($name, $phone, $zip=){
 if (!$zip)  $zip = ;
 echo $name.$phone.$zip
}

HTH
Martin

-Original Message-
From: Shane [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 11, 2002 10:14 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Easy Function Question?


I have a need to call a function, where all the variables used might not be
set. Is there a way to have a variable in a function have a default setting
if the variable passed to the function is VOID?

EXAMPLE:

$name=me;
$phone=;
//$zip is VOID

function myFunction($name, $phone, $zip){
 echo $name.$phone.$zip
}

can I write...?

function myFunction($name, $phone, $zip=){
 echo $name.$phone.$zip
}

and then $zip will have a value of  if $zip is VOID for some reason...?

I thought it was something like this, but I keep batting ZERO and there is
no mention of this problem in the places I looked in the docs.

Can anyone throw me a bone?
Thanks gang!

-NorthBayShane

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php