Consider the following two coding styles:
Nested Conditions:
if(is_numeric($user_id)) { // .. do stuff if(is_valid_user($user_id)) { return foo($user_id); } else { return FALSE; } } else { return FALSE; }
vs. just stopping when something is wrong:
if(!is_numeric($user_id)) { return FALSE; } // .. do stuff if(!is_valid_user($user_id)) { return FALSE; } return foo($user_id);
This, of course, is at least partially about taste; but what are these two different styles called?
When do you prefer each other?
Are there other, possibly cleaner coding styles?
source share