note 111343 deleted from function.exit by mazzanet
| From: | mazzanet@php.net | Date: | Sun, 10 Aug 2014 09:10:12 +0000 |
| Subject: | note 111343 deleted from function.exit by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-200153@lists.php.net to get a copy of this message | ||
Note Submitter: Jorge Castro
----
Another way to avoid exit is to add a conditional branch (i.e. an if).
<?php
$task=someoperation();
if (!$task) {
// for example, the task failed so we exit asap.
exit();
}
//... rest of the code...
?>
is analog to :
<?php
$task=someoperation();
if (!$task) {
// the task failed, so we do nothing and "jump" to the end of the code
//... rest of the code...
}
?>
Most of the case, to use exit is cleaner than to add a big branch.