|
Posted by Jerry Stuckle on 11/29/07 12:50
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'.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|