Reply to Re: short if else

Your name:

Reply:


Posted by David Haynes on 12/28/05 14:31

iuz wrote:
> Kimmo Laine wrote:
>
>> "Moneypenny" <geld2008@planet.nl> wrote in message
>> news:43b26e2f$0$10079$ba620dc5@text.nova.planet.nl...
>>> Hy,
> [..]
>> $test==1 ? $do = true : $do = false;
>> $test==1 ? $who = 'me' : 0 ;
>>
>> (in this particular case it could be expressed as:
>> ($do = $test==1) ? $who = 'me' : '';
>> in order to make it really short)
>>
>> You _could_ do it the way you intended to do it, but that would be bad
>> coding practise, so I'm not gonna say how.
>>
>
> but this way the third part of the ternary operator is not required so..
> $do = $test == 1 && $who = 'me';
> IMHO is the shortest way to make it..
>
Leaving issues such as maintainability and clarity aside...

$do = $test && $who = 'me';

Since $do = $test will be resolved as boolean by the && operator.

-david-

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация