NYCPHP Meetup

NYPHP.org

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

Chris Shiflett shiflett at php.net
Tue Jan 31 18:21:15 EST 2006


Carlos A Hoyos wrote:
> 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).

$result = max($calculation, 0);

I'm too sexy. :-)

Chris

-- 
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/



More information about the talk mailing list