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

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -