Re: how to pass true/false or "no argument"
| From: | John A. Grant | Date: | Mon, 29 Oct 2001 17:56:23 +0000 |
| Subject: | Re: how to pass true/false or "no argument" | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-72752@lists.php.net to get a copy of this message | ||
"John A. Grant" <jazrant@zsc.nrcan.zc.ca> wrote in message
news:20011029170132.18355.qmail@pb1.pair.com...
[...]
> How do I distinguish between false and "$xxx parameter not
> passed"? Do I use isset()? Do I use ===?
Well, I guess I should have done some homework first. This
code seems to work fine:
function somefunction($text,$xxx=null)
{
if(isset($xxx)){
echo $xxx ? "true" : "false";
}else{
echo "null";
}
echo "\n";
}
somefunction("hello");
somefunction("hello",true);
somefunction("hello",false);
It prints:
null
true
false
which is what I want.
--
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