
In the previous 2 weeks, we’ve looked at how to use CSS shorthand to reduce the size of your stylesheets, and how to speed up the development of HTML pages.
In this week’s quick and dirty set of tips, we’re going to look briefly at optimizing PHP code.
Increasing Site Performance In PHP
Unlike optimizing your CSS code, usually your main goal in optimizing PHP code is not to cut down on file size, but rather speed up the loading and performance of your pages.
Knowing the most efficient ways to get what you want accomplished in PHP can give your pages a boost as far as processing and loading speed.
Here are 3 tips to help you optimize your PHP code and make your pages load faster:
- If a method can be static, declare it static. Speed improvement is by a factor of 4.
- echo is faster than print.
- Use echo’s multiple parameters instead of string concatenation.
Source: Reinhold Weber
Read all 40 PHP optimization tips
Is It Worth Optimizing My Code?
If you follow the above optimizations, just how much will these speed up your site?
When optimizing any type of code, it’s important to keep in mind that the time spent optimizing your code may be better spent if it’s only going to improve performance slightly.
Some of the tips listed above may not improve performance or speed enough to be worth the time invested in optimizing you PHP.
Devolio has a great post (with graphs and charts and statistics) showing which PHP optimization tips work, and how much impact these have on loading and performance speed.
Practical (and Impractical) PHP Optimizations
As with optimizing in general, moderation is important. I don’t believe all the 40 optimization tips should be used, but there are several that can greatly improve your pages performance.
More Quick and Dirty Tips
- CSS Shorthand Tips
- Lightning Fast Page Setup
- Optimizing PHP Code (For Fun and Profit)
Subscribe to our RSS feed and look for new installments of Quick and Dirty Tips.

You should

No comments yet.
Subscribe to the Comments RSS feed—Follow the discussion.
Leave a comment
Note: All links in the comments are set to 'nofollow'. Search engines will not follow or index those links.
Follow this post's comments by subscribing to the Comments RSS feed.