Jump statements (return, break, continue, and goto) and throw expressions move
control flow out of the current code block. Typically, any statements in a block that come after a jump or throw are simply wasted
keystrokes lying in wait to confuse the unwary.
Rarely, as illustrated below, code after a jump or throw is reachable. However, such code is difficult to understand, and should be
refactored.
function fun($a) {
$i = 10;
return $i + $a;
$i++; // this is never executed
}
function foo($a) {
if ($a == 5) {
goto error;
} else {
// do the job
}
return;
error:
printf("don't use 5"); // this is reachable but unreadable
}
function fun($a) {
$i = 10;
return $i + $a;
}
function foo($a) {
if ($a == 5) {
handleError();
} else {
// do the job
}
return;
}