globalwarming awareness2007

Optimize PHP, Part 1

View days ago i am searching solutions for any tips and tricks about
best practice to optimize PHP code performances and i found some of
useful articles which you may interested with. some of article resume

  • echo is faster than print.(* compare with list from phplens by John Lim)
  • Use full paths in includes and requires, less time spent on resolving the OS paths.
  • Unset your variables to free memory, especially large arrays.
  • Set the maxvalue for your for-loops before and not in the loop.
  • str_replace is faster than preg_replace, but strtr is faster than str_replace by a factor of 4
  • Error suppression with @ is very slow.
  • Turn on apache’s mod_deflate
  • Close your database connections when you’re done with them
  • $row[’id’] is 7 times faster than $row[id]
  • If you need to find out the time when the script started executing, $_SERVER[’REQUEST_TIME’] is preferred to time()


Thank you for reading this post. You can now Leave A Comment (0) or Leave A Trackback.



Leave a Reply

Note: Any comments are permitted only because the site owner is letting you post, and any comments will be removed for any reason at the absolute discretion of the site owner.

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-Spam Image