this question has answer here:
- boolean value switch/invert 6 answers
let's have following function should return true
if valid , false
if invalid.
is there shortcut return 'opposite' of boolean $this->errors
?
should use one-line if statement
or there possibilty?
so if $this->errors
false
want return true
:p
function valid() { $this->errors = false; if ($somethingiswrong) { $this->errors = true; } return $this->errors; }
edit
omg how come never see right questions/answers when use search option. find right answers when posted :p
return !$this->errors;
is looking for.
return !$this->errors;
Comments
Post a Comment