Php optimize

Quick Links

Image Upload and Resize with PHP (

Applets and Proxy Detection (

Using RAID on Fedora Core (

If you have come here to find out whethere print is better than echo, or if require is superior to include you are just wasting your time. The performance of PHP web applications cannot be improved by such tactics. Changing the oil in your car with a faulty engine will not make it go faster.

Speed of PHP scripts, or any application for that matter lyes in the algorithm you use. If you think your application is not running as fast as it should, or your web server cannot serve as many users as you want it to, take a close look at your design and see if the logic can be changed.

Once you have improved the design, we can look at ways of making small modifications to the code that may make significant improvements to the scripts performance. However we should be carefull not to change the code in way that might make it run faster but consume more memory. With such scripts speed is an illusion; When n number of users are browsing your site simultanously physical memory will be exausted and the system will start swapping, the slow down will be dramatic.

Before we get too deeply into it, the author will attempt to show that performance benchmarks should generally be taken with a large spoonfull of salt. We will not rely on the time() function of php to judge how good a script is but make use of xdebug ( Xdebug can tell you how much memory your script consumes, but compiling php with the --enable-memory-limit option is a must.

So before we proceed to the next step please take a moment to download and install xdebug and recompile php with the --enable-memory-limit setting if you have not already done so.