|
Posted by taps128 on 11/29/07 21:47
Jerry Stuckle wrote:
> taps128 wrote:
>> Toby A Inkster wrote:
>>> jodleren wrote:
>>>
>>>> $err = somefunc();
>>>> if($err===true)
>>>> echo "ok"
>>>> else
>>>> echo "error: $err";
>>>
>>> echo (true === ($err = somefunc())) ? 'ok' : "error: $err";
>>>
>>> :-)
>>>
>> or more readable(to me) IMHO
>> $err=foo();
>> switch($err){
>> case true: echo 'ok';break;
>> case false: echo 'error: '.$err;
>> }
>>
>> But of course thats just a matter of style.
>>
>
> More than a matter of style. If the function returns '1', your way will
> print 'ok', while Toby's function will return the more correct 'error: 1'.
>
>
>
You right, i missed those '==='
[Back to original message]
|