#46158 [Opn->Bgs]: Break out of compound blocks.
| From: | johannes@php.net | Date: | Tue, 23 Sep 2008 11:20:38 +0000 |
| Subject: | #46158 [Opn->Bgs]: Break out of compound blocks. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-129203@lists.php.net to get a copy of this message | ||
ID: 46158
Updated by: johannes@php.net
Reported By: kok at nachon dot nl
-Status: Open
+Status: Bogus
Bug Type: Feature/Change Request
Operating System: Irrelevant
PHP Version: 5.2.6
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Adding this functionality would break scripts, so we'd need a new
keyword which has issues...
A suggested work-around is like that:
if ($foo) {
do {
if (do_something()) {
break;
}
do_more();
} while (0);
}
Previous Comments:
------------------------------------------------------------------------
[2008-09-23 11:01:41] kok at nachon dot nl
Description:
------------
I read in Bug #29287 about breaking out of loops and was wondering if
anyone considered breaking out of a generic compound block. This would
satisfy the need for error handling without goto.
Example:
function connect() {
{ //start compound block
if (!mysql_connect('host', 'user', 'pass)) break; //break out
if (!mysql_select_db('database')) break; //break out
return;
}
$code = mysql_errno();
$msg = mysql_error();
throw new Exception($msg, $code);
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46158&edit=1