This was a long problem that I encountered in many coding sessions with hot and pair modes.
One person encodes this code this way. So after much jolting and stress, I'm curious ... Is there any correct way to express the PHP expression “IF ELSE”?
Personally, I use:
if ($variable == 'setvalue') { $variable = executefunctiononvariable($variable); } else { $variable = executedifferentfunctiononvariable($variable); }
After many arguments, although other options were presented to me, such as:
if ($variable == 'setvalue') { $variable = executefunctiononvariable($variable); } else { $variable = executedifferentfunctiononvariable($variable); }
OR
if ($variable == 'setvalue') $variable = executefunctiononvariable($variable); else $variable = executedifferentfunctiononvariable($variable);
OR
if ($variable == 'setvalue') { $variable = executefunctiononvariable($variable); } else { $variable = executedifferentfunctiononvariable($variable); }
code-formatting php semantics if-statement readability
privateace
source share