note 50911 deleted from control-structures.break by felipe

From: Date: Tue, 29 Jan 2008 11:27:00 +0000
Subject: note 50911 deleted from control-structures.break by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-135530@lists.php.net to get a copy of this message
Note Submitter: php_manual at pfiff-media dot de ---- instead of using the while (1) loop with break like suggested in an earlier note, I would rather recommend throwing an exception, e.g.: <?php try { $query = "SELECT myAttr FROM myTable"; $db = DB::connect($dbUrl); if (DB::isError($db)) { throw new Exception("Connection failed"); } /* ... */ } catch (Exception $e) { echo "Error: ".$e->getMessage()."</br>"; } ?>

« previous php.notes (#135530) next »