if(specific condition) {success}
else(everything else in the world including unforeseen events){failure}
or in this case
i said it makes little difference in this example but it is best practice. (high assurance programming languages place constraints on the variables that are checked every single time the variable is used to prevent problems that may arise from any type of corruption like magnetic fields or overheating processors.)PHP Code:function lenCheck( $var, $maxlen ) {
if (strlen($var) <= $maxlen) {
return true;
} else {
return else;
}
}
if you always match what you want and fail everything else you will increase your odds of failing good data and decrease passing bad data. this is good because an exception will be less likely of resulting in an exposure and good data failing is easier to catch in test then bad data passing is.




Reply With Quote