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: Wont fix
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: *
PHP Version: *
Block user comment: N
Private report: N
New Comment:
This syntax is causing problems for some because it violates the KISS principles. Since
"else" is used for conditions, and since you can write conditions and loops without curly
brackets, it could cause confusion to a lot of people.
I proposed "iterated" (if at least 1 iteration) and "none" ("else") as
replacements, but this request has been rejected shortly after...
Previous Comments:
------------------------------------------------------------------------
[2017-06-27 10:46:32] php at pointpro dot nl
This syntax would indeed be great. I see that the vote was not passed at the RFC, but I don't
see any argumentation why.
Other languages don't have it is not true, and also not a reason to not add it.
What are arguments against having such a useful construct?
------------------------------------------------------------------------
[2017-06-17 16:28:03] rageclick at gmail dot com
I almost never join conversations or write comments online but I would also love to see this feature
as well. It's just nicer, easier to look at and it uses less code which is what I go for.
However... if there is a reason behind why you won't do this, I would understand.
while ($result = $get->fetch_assoc()) {
$in=1;
echo 'Something';
}
if(!$in){ echo 'Nothing'; }
WHEN I could be doing this
while ($result = $get->fetch_assoc()) {
echo 'Something';
}else{ echo 'Nothing'; }
------------------------------------------------------------------------
[2016-05-10 13:56:48] asd at asd dot asd
Hey, it's an awesome feature everyone would like. Let's reject it!
------------------------------------------------------------------------
[2016-05-04 13:26:08] nikic@php.net
Related To: Bug #72148
------------------------------------------------------------------------
[2015-06-10 12:11:38] cmb@php.net
Related To: Bug #67843
------------------------------------------------------------------------
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