TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

40 Tips for optimizing your php Code

13 点作者 raindoll超过 17 年前

3 条评论

some超过 17 年前
&#62; 1. If a method can be static, declare it static. Speed improvement is by a factor of 4.<p>Wow!<p><pre><code> function Prime1() { ...calc one million prime numbers...} static function Prime2() { ...calc one million prime numbers...} </code></pre> Prime2() will calculate the prime numbers 4 times faster then Prime1()? Cool.
jbyers超过 17 年前
These range from sensible to utterly useless [1,2,3].<p>I'd say forget all of this and focus on being a productive developer, building something people want, and ruthlessly avoiding premature optimization. When your application is slow, measure it to find out why, then fix it, and repeat.<p>1. Let's take #2, "echo is faster than print" - Seriously, is this what we should be worrying about? I can't detect a difference in PHP 5.2.4 across 100,000 echos/prints, so it must not be very big.<p>2. ++i vs i++ to squeeze out 1 fewer opcode?<p>3. Using isset($foo{5}) vs a strlen check? I pity the next programmer who has to read and understand the purpose of this code.
some超过 17 年前
&#62; Set the maxvalue for your for-loops before and not in the loop.<p>What does this mean?
评论 #68057 未加载