The shorter the code (up to a point!) the better.
You should tell your code what to do. You should not be asking your code, if you are allowed to tell it what to do. Your coding, like love, should be Unconditional!
Need more arguments?
&&
is better:
Conditionals aren't always bad, but they can be (and frequently are) abused. source
Some clever developers built-in similar solution directly into PHP
, @Madara Uchiha the null coalescing operator ??
i.e. was introduced to PHP.
Functionally they will produce the same result. But one (&&
) says you are a quality programmer, the other (if
) says you are doing it as a side hussle.
Stop being scared of your code.
Be proud of your code.