News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Alex Netkachov's Blog:
PHP micro-optimization tips
March 10, 2009 @ 08:47:38

For those trying to squeeze the absolute most out of their applications, check out these suggestions from Alex Netkachov on a few "micro" kinds of things that could help speed things up in the long run.

Why "micro-"? Because changing logic of your application may give you much better performance boost then applying all these tips. But they still can make your code better. You always need to output something, why do not use "echo" instead of "print"?

He has a list of about thirty things you can do including:

  • calling a function is faster then calling a static method
  • accessing an initialized variable is faster then accessing an uninitialized variable
  • avoid @ (error control operator)
  • adding method parameter type hint increases calling time
  • cache page output or result of resource-consuming functions
  • pre-increment (++$i) is faster then post-increment ($i++)
  • an array is a faster alternative to a class with several fields

These hints aren't going to make amazing differences in your code, but they could help get you out of a sticky place where your code just doesn't want to behave.

0 comments voice your opinion now!
microoptimization tip small hint


blog comments powered by Disqus

Similar Posts

Jeez Tech: Damn Small PHP Frameworks. Because size does matter.

Blue Parabola Blog: Writing Tech Books 101

Pierre-Alain Joye's Blog: Howto use a single php.ini for cli/cgi with htscanner, use 0.7.0 or later

Jani Hartikainen's Blog: Static/Dynamic typing sweet spot

Matthew Weier O'Phinney: Deployment with Zend Server (Part 8 of 8)


Community Events





Don't see your event here?
Let us know!


list community introduction tool series podcast interview framework version opinion laravel conference voicesoftheelephpant language security library example symfony package composer

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework