how to pass true/false or "no argument"
| From: | John A. Grant | Date: | Mon, 29 Oct 2001 16:50:18 +0000 |
| Subject: | how to pass true/false or "no argument" | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-72743@lists.php.net to get a copy of this message | ||
I've written several functions with optional "string" parameters.
They work fine. But I've never written one that accepts an optional
"bool" parameter and I'm now confused.
I would like to have this:
somefunction("hello");
somefunction("hello",false);
somefunction("hello",true);
function somefunction($text,$xxx="")
{
if($xxx){
$xxx parameter was passed as true or false
}else{
$xxx parameter was not passed
}
}
Which is correct for the default initialization of $xxx:
$xxx=false;
$xxx=null;
$xxx="";
How do I distinguish between false and "$xxx parameter not
passed"? Do I use isset()? Do I use ===?
Thanks.
--
John A. Grant * I speak only for myself * (remove 'z' to reply)
Radiation Geophysics, Geological Survey of Canada, Ottawa
If you followup, please do NOT e-mail me a copy: I will read it here