Re: Re: New Operator
| From: | Cristiano Duarte | Date: | Tue, 14 Mar 2006 20:55:05 +0000 |
| Subject: | Re: Re: New Operator | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-22427@lists.php.net to get a copy of this message | ||
Brian Moon wrote:
>>> $ConfirmCode = (isset($_GET['ConfirmCode']) ?
>>> $_GET['ConfirmCode'] :
>>> '');
>> I agree that this is really a PITA, but until we get an operator for
>> this, we should stuck on the ternary.
>
>
> Another option is to use settype(); This has two advantages. One, if
> the variable does not exist, settype creates it with an empty value of
> the given type. Second, if it does exist, it can semitypecast them for
> you.
>
> settype($_GET['ConfirmCode'], "string");
>
> or
>
> $ConfirmCode = $_GET["ConfirmCode"];
> settype($ConfirmCode, "string");
But you still don't have a default value, just an empty default
value(string, zero, etc.). You can't i.e. initialize $_GET["ConfirmCode"]
with "Yes" using settype...
Regards,
Cristiano Duarte