note 75908 added to control-structures.else
| From: | robbak at osu1 dot php dot net | Date: | Thu, 21 Jun 2007 07:54:47 +0000 |
| Subject: | note 75908 added to control-structures.else | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-127850@lists.php.net to get a copy of this message | ||
Yes, that code is clearly ambiguous. I would think that the code does the 'right thing'
with it anyway. The else should bind to the nearest if.
If you are going to nest ifs, use curly brackets and stay sane.
<?
if ($a == 1)
{ /* nested if */
if ($b == 2) echo '2';
} else
/* other code */
?>
----
Server IP: 69.147.83.197
Probable Submitter: 124.148.75.42
----
Manual Page -- http://www.php.net/manual/en/control-structures.else.php
Edit -- https://master.php.net/note/edit/75908
Del: integrated -- https://master.php.net/note/delete/75908/integrated
Del: useless -- https://master.php.net/note/delete/75908/useless
Del: bad code -- https://master.php.net/note/delete/75908/bad+code
Del: spam -- https://master.php.net/note/delete/75908/spam
Del: non-english -- https://master.php.net/note/delete/75908/non-english
Del: in docs -- https://master.php.net/note/delete/75908/in+docs
Del: other reasons-- https://master.php.net/note/delete/75908
Reject -- https://master.php.net/note/reject/75908
Search -- https://master.php.net/manage/user-notes.php