|
|
|
|
|
by selfsimilar
3406 days ago
|
|
In PHP I like using Yoda Conditions because there's a common idiom of testing assignment in the conditional: if ($value = getSomeValue()) {
// Safely use value
}
Yoda Conditions defend nicely against accidents when '=' and '==' can be used legally this way and honestly you get used to reading them pretty quick. |
|
C++, for instance however has language syntax to prevent confusion when using this idiom – declarations inside conditionals:
Considering that PHP already has the useless var keyword, they might just adopt something similar in the future