From: Jason R. <ja...@ho...> - 2009-03-30 20:47:29
|
The example they give on the man page is enlightening if you think about it from the point of view of some college kid who had java or .net classes and is learning PHP on the job doing maintenance on some legacy code base: <?php // Example usage for: Ternary Operator $action = (empty($_POST['action'])) ? 'default' : $_POST['action']; // The above is identical to this if/else statement if (empty($_POST['action'])) { $action = 'default'; } else { $action = $_POST['action']; } ?> While the ternary operation is shorter and more terse, the standard if/else method will be easier for them to follow. Again, its about survivable code not shortest code. In order to survive it has to live in the real world which often has people of various skill levels interacting with it over time.. But, I'm just a curmudgeon ;-) Jough Dempsey wrote: > On Mon, Mar 30, 2009 at 1:07 PM, Wilfried Schobeiri <ws...@de...> wrote: > >> Was hoping that http://wiki.php.net/rfc/ifsetor/s suggested "?:" would >> be accepted. > > It was. You can short-circuit ternary operations in PHP 5.3: > > http://us2.php.net/ternary > > ------------------------------------------------------------------------------ > _______________________________________________ > chiPHPug-discuss mailing list > chi...@li... > https://lists.sourceforge.net/lists/listinfo/chiphpug-discuss |