BIRT 3.7
Written by: Michael Williams
Featured Refcardz: Top Refcardz:
  1. HTML5 Canvas
  2. Ruby
  3. iPhone/iPad
  4. Spring Web Flow
  5. REST
  1. jQuery Selectors
  2. Spring Config.
  3. Java
  4. Ajax
  5. Java Concurrency

Link Details

Link 203564 thumbnail
User 411546 avatar

By Effadreen
via weblenium.com
Published: Jul 18 2009 / 05:07

A list of PHP optimisation tips.
  • 8
  • 7
  • 1840
  • 0

Comments

Add your comment
User 378984 avatar

topbit.co.uk replied ago:

2 votes Vote down Vote up Reply

A link, to a link, to failure. If Google can screw it up with 5 tips, imagine 10x more failure with pretty pointless 'tips'.

Index you database, cache your byte-code and the output. Don't bother with the micro-optimisations.

User 368023 avatar

yakkoh replied ago:

0 votes Vote down Vote up Reply

I don't understand why (if there are no side effects) ++$i is faster than $i++; the 'compiler' should view both forms as ++$i.

User 349415 avatar

mheath.myopenid.com replied ago:

0 votes Vote down Vote up Reply

Isn't "PHP optimisation" an oxymoron?

User 204824 avatar

suresk replied ago:

0 votes Vote down Vote up Reply

Micro-tuning is fun, but not terribly useful in most cases. In most web applications, the performance bottleneck is in interacting with external services - typically a database. Performing all of these optimizations will typically net you less time than the standard deviation of a single database call - meaning the performance improvements simply get lost in the noise.

There are lots of ways to get your web app to perform better. Micro optimizations that net you a few microseconds here and there should be pretty far down on the list.

User 214919 avatar

scotty79 replied ago:

0 votes Vote down Vote up Reply

True optimization tip for php is "Don't do stupid things".

You got three or more levels of nesting in your loops?
Do you pull a lot of data from sql to calculate some summary with php that could be done in sql instead?
Do you use loop if the function exists that will do the same with single call?
Do you include lots of files and not use APC cache (or equivalent)?
Do you use files to store your data?
Do you process more than few hundred kB of data in single script?
Don't you use cache to speed up long operations that calculate rarely changing values?
Do you eval often ?

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.