|
Posted by Oli Filth on 12/28/05 16:56
Oli Filth said the following on 28/12/2005 14:53:
> David Haynes said the following on 28/12/2005 14:42:
>
>> Oli Filth wrote:
>>
>>> black francis said the following on 28/12/2005 14:37:
>>>
>>>> try:
>>>>
>>>> $do = ($test == 1) ? true : false;
>>>
>>>
>>>
>>> Well, that can be shortened to:
>>>
>>> $do = ($test == 1);
>>>
>>>
>> Which can be shortened to:
>>
>> $do = $test;
>>
>> unless $test = 0, $do will evaluate as false.
>>
>
> Technically, it's not the same. In the first two examples, $do will
> *always* be a boolean. But in your new version, $do could be anything,
> dependent on what type $test is.
>
Oh, and another thing. With:
$do = ($test == 1);
$do will resolve to true *only* if ($test == 1), i.e. will resolve to
false for any other value of $test.
With:
$do = $test;
$do will resolve to false *only* if ($test == 0), i.e. will resolve to
true for any other value of $test.
--
Oli
Navigation:
[Reply to this message]
|