High Performance PHP
-
Did you know that the fastest way to check in PHP to see if you’re running on windows is:
$iswindows = DIRECTORY_SEPARATOR == '\\\\';or the fastest way to get the time without even calling a function is:
$currenttime= $_SERVER['REQUEST_TIME'] ;These are some of the optimization methods mentioned over the slides by Ilia Alshanetsky on High Performance PHP. Browse the slides to learn more optimizations you can perform on your code to improve performance:
Advertisement
2 Comments
Leave a Comment
























October 12th, 2006 at 2:27 pm
Unfortunately, that time method is not completely foolproof, especially when you have scripts that take a while to run. The windows detection is a nice one, but of course you will only detect if your server is running windows. This should not be very necessary, since usually, especially with such heavy applications, you should know which server your application is developed for.
Still, some useful tips there.
October 12th, 2006 at 3:21 pm
There are a few more tips like avioding the use of the @ operator to supress error messages. That actually brought down by three times the performance in the benchmark script which is provided.