> 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.
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.