NYCPHP Meetup

NYPHP.org

[nycphp-talk] How to return a calculated result or zero

Carlos A Hoyos cahoyos at us.ibm.com
Tue Jan 31 18:15:14 EST 2006


Sorry to nit-pick, but why is this one so ugly? I might come from the "c"
school, but I honestly find

$result = ($calculation > 0) ? $calculation : 0;

easy to read (and a little sexy too).

If you want a math formula, how about:

$result = ($calculation + sqrt($calculation * $calculation)) / 2;

now if you ask me, that one is ugly, ugly, ugly ;-)



talk-bounces at lists.nyphp.org wrote on 01/31/2006 05:45:32 PM:

> This has been driving me nuts:
>
> $result = ($some calculation > 0)
>                    ? $some calculation
>                     : 0;
>
> Sure it works, but ugly, ugly, ugly...




More information about the talk mailing list