I\'ve heard of some performance tips for PHP such as using strtr()
over str_replace()
over preg_replace()
depending on the situation.
You must measure before you optimize. Without measurements, you cannot have goals. Without goals, you are wasting your time.
If you discover that your webpage takes 250ms to render, is that fast enough? If not, how fast should it be? It won't get down to zero. Do you need it to be 200ms?
Use a tool like XDebug (http://www.xdebug.org/) to determine where the hotspots in your code are. Chances are you will find that your app is taking 80% of its time accessing the database. If your app is taking 200ms to get data from the database, and .01ms in str_replace
calls, then the speedups of going to strtr
, or of using echo
instead of print
are so small as to be irrelevant.
The dream of being able to use strtr
instead of str_replace
and get noticeable, measurable speedups is a fantasy.