This question already has an answer here:
- Using return in ternary operator 7 answers
I was recently refactoring. And thought this would awesome. But is not allowed.
<?php
function(){
doSomething() && return true;
}
</div>
This question already has an answer here:
I was recently refactoring. And thought this would awesome. But is not allowed.
<?php
function(){
doSomething() && return true;
}
</div>
Because return
is a statement and cannot be used as part of an expression. An expression is something that returns/results in a value. return
doesn't result in any value, but operands to &&
must result in a value for the &&
expression to be evaluable.