Edit report at https://bugs.php.net/bug.php?id=26411&edit=1
ID: 26411 Comment by: bensor987 at neuf dot fr Reported by: php at bellytime dot com Summary: while {} else {} Status: Open Type: Feature/Change Request Package: Scripting Engine problem Operating System: * PHP Version: * Block user comment: N Private report: N New Comment: I understand your opinion. You want to make the "else" keyword usable only when "false" is encountered, like in "if...else". I didn't think about this. In that case, let's use another keyword, because this syntax is an excellent idea. Why not this ? <?php while ($row = mysql_fetch_assoc($result)) { print 'Here is a result'; ... } none { print 'No results found'; } ?> Previous Comments: ------------------------------------------------------------------------ [2012-08-22 17:05:05] ras...@php.net It's not that simple. Loops are repeatedly evaluated conditions. It isn't clear whether adding an else clause would only apply to the first evaluation or also subsequent ones. ------------------------------------------------------------------------ [2012-08-22 16:46:52] bensor987 at neuf dot fr "no such syntax in other languages"....what do you mean ? PHP doesn't have the right innovate ? I see plenty of cases I would use this syntax. The "else"s would be triggered if there hasn't been any iteration in the loop. It means : less variables to use (so less memory usage), less code lines, etc... There are only advantages to this syntax (and it's pretty simple to understand, no KISS violation here). It's not because it isn't done by other languages that we shouldn't implement it. ------------------------------------------------------------------------ [2012-08-22 10:44:30] ni...@php.net Python has an "else" for loops, but it means something completely different. ------------------------------------------------------------------------ [2012-08-22 10:29:25] hawkyhawk14 at gmail dot com larue...@php.net no such syntax in other languages. --------------------------------- Python has it and some versions of BASIC have it aswell. ------------------------------------------------------------------------ [2012-08-22 10:09:30] ni...@php.net Revert status change. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=26411 -- Edit this bug report at https://bugs.php.net/bug.php?id=26411&edit=1