You are here: Re: Breaking backwards compatibility - good or bad? « PHP Programming Language « IT news, forums, messages
Re: Breaking backwards compatibility - good or bad?

Posted by Martin Lucas-Smith on 12/21/05 14:06

On Wed, 21 Dec 2005, tony@marston-home.demon.co.uk wrote:

> > So, PHP makers, if you are reading this:
> Please, please, please, *PLEASE* drop the ternary operator from future
> PHP versions! Just read the legacy code I'm confronted with and you
> understand why.
>
> Now there I would agree 100%. Every time I see the ternary operator I
> want to puke.


Why? Once you know it exists, it makes coding certain things very much
more efficient, e.g.


echo "You have $total " . (count ($total) == 1 ? 'item' : 'items') . '.';


rather than the verbose


if (count ($total) == 1) {
$tempWord = 'item';
} else {
$tempWord = 'items';
}
echo "You have $total {$tempWord}.";
unset ($tempWord);



or

$foo = (isSet ($_GET['foo']) ? $_GET['foo'] : 'default');


It's not as if this construct only exists in PHP.



Martin

 

Navigation:

[Reply to this 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

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