Say I have something like this:
switch ($_GET['func']) {
case 'foo':
dobar();
break;
case 'orange':
if ($_GET['aubergine'] == 'catdog') {
// **DO DEFAULT OPTION**
} else {
dosomethingElse();
}
break;
default:
doDefault();
}
How can I jump to the default
case from the marked spot in case 'orange'
?
Try:
switch($_GET['func']) {
case 'foo':
dobar();
break;
case 'orange':
if($_GET['aubergine'] != 'catdog') {
dosomethingElse();
break;
}
default:
doDefault();
}
Yo dawg, you can use a cool new feature called the goto.
<?php
$func = "orange";
function doDefault() { echo "yeehaw!"; return; }
function dobar() { return; }
function dosomethingElse() { return; }
switch ($func) {
case 'foo':
dobar();
break;
case 'orange':
if (true) {
goto defaultlabel;
} else {
dosomethingElse();
}
break;
default:
defaultlabel:
doDefault();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With