Click to See Complete Forum and Search --> : difference in comparisons


bsgrules
06-30-2005, 03:50 AM
Can someone tell me if doing something like this is a bad idea.

empty($foo) and $bar = 'foobar';


as opposed to this


if (empty($foo)) {
$bar = 'foobar';
}

rebelo
06-30-2005, 04:56 AM
If nothing else, I'd consider nothing other than the second option simply for readability.

bsgrules
06-30-2005, 11:35 PM
Anyone else have any comments to make?

Drakla
07-01-2005, 12:07 AM
Well it's obvious what it does, and if you're programming for yourself on something tiny and simple then why not, but if I had to take another programmer's source code and it was full of stuff like that I'd track him down and make him drink Sunny Delight.... through my knickers.