php - Variables: overwriting vs if/else -
this php question applicable other languages.
which better way handle variable assignments?
// use default value , overwrite $var_one = 'x'; if ($var_two) { $var_one = 'y'; } // use complete if/else if ($var_two) { $var_one = 'y'; } else { $var_one = 'x'; }
i'm curious how software works @ lowest levels.
i use first 1 because remove 1 process. cleaner second one:
$var_one = 'x'; if ($var_two) $var_one = 'y';
or
$var_one = ($var_two ? 'y' : 'x');
the above code cleaner #1 example.
Comments
Post a Comment