I have a class with a protected variable in it which can be get by a function getVariable()
.
How much difference will it make if i'll call getVariable()
every time instead of storing the result once and then use it? (the getVariable(开发者_如何学编程)
does nothing more than return $this->var
)
It should not matter either way for you, premature optimization is bad. Do what makes sense design wise, not optimization wise. Either way, function/method calls in php are pretty cheap.
精彩评论