开发者

Store function result or call it each time? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜