6
devRow
7y

function toCodeOrNotToCode() {
if (!isset($coffeeOrRedbull)) {
die('No work can be done');
} else {
return true;
}
}

// I don't drink Redbull daily

Comments
  • 0
    Why not flip the if and else? Makes it more readable
  • 0
    The variable is always set if it's defined and has a value above null and will therefore evaluate to true when checking via isset, right?
  • 1
    @RAZERZ you can set the variable to NULL to start out with. The !isset will return true in that case.

    $coffeeOrRedbull = NULL;
  • 1
    @illfamed cool!
Add Comment