Re: how to pass true/false or "no argument"
| From: | Papp Gyozo | Date: | Tue, 30 Oct 2001 13:31:32 +0000 |
| Subject: | Re: how to pass true/false or "no argument" | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-72908@lists.php.net to get a copy of this message | ||
another approach: func_num_args().
http://www.php.net/manual/en/function.func-num-args.php
----- Original Message -----
From: "Henrik Hudson" <lists@rhavenn.net>
To: "John A. Grant" <jazrant@zsc.nrcan.zc.ca>; <php-general@lists.php.net>
Sent: Monday, October 29, 2001 9:06 PM
Subject: Re: [PHP] how to pass true/false or "no argument"
> If $xxx isn't defined at all, its default is NULL, so your if statement
> should work as is. If $xxx is not defined, then you should get thrown down
to
> the else. There is a difference between false and NULL.
>
> On Monday 29 October 2001 10:50, John A. Grant wrote:
> > 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.
>
> --
>
> Henrik Hudson
> lists@rhavenn.net
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>