php - Is it better to get values from array or declaring them each time? -
example 1:
$a = 'value1'; $b = 'value2'; $c = 'value3'; $x = 'value1'; $y = 'value2'; $z = 'value3';
example 2:
$var = array('value1', 'value2', 'value3'); $a = var[0]; $b = var[1]; $c = var[2]; $x = var[0]; $y = var[1]; $z = var[2];
which example has less server resource usage? example faster?
in neither has impact on speed trivial. if talk memory usage, array uses more stores same variables + reffence links (again, trivial how works). there other factors need consider:
1.readability - if use array approach code dificult trace in bigger functions.
2.operations - if use array array approach operations variables limited things += break array refference , store values directly in variable.
3.relations other devs - if use array approach else has work code spilling curses way ;)
Comments
Post a Comment