come on babay

come on babay,Love me ,love yourself.

2007/06/24

 

PHP的12条小提醒

blog上看到了这个东东,自己觉得受益匪浅,不敢独享,和大伙分享一下。
  1. If a method can be static, declare it static. Speed improvement is by a factor of 4.
  2. Avoid magic like __get, __set, __autoload
  3. require_once() is expensive
  4. Use full paths in includes and requires, less time spent on resolving the OS paths.
  5. If you need to find out the time when the script started executing, $_SERVER['REQUEST_TIME'] is preferred to time()
  6. See if you can use strncasecmp, strpbrk and stripos instead of regex
  7. preg_replace is faster than str_replace, but strtr is faster than preg_replace by a factor of 4
  8. If the function, such as string replacement function, accepts botharrays and single characters as arguments, and if your argument list isnot too long, consider writing a few redundant replacement statements,passing one character at a time, instead of one line of code thataccepts arrays as search and replace arguments.
  9. Error suppression with @ is very slow.
  10. $row['id'] is 7 times faster than $row[id]
  11. Error messages are expensive
  12. Do not use functions inside of for loop, such as for ($x=0; $x < count($array); $x) The count() function gets called each time.


--
我的网络营销boogger
http://china-news-it.blogspot.com





<< 主页

存档

2007/4/8 - 2007/4/15   2007/4/15 - 2007/4/22   2007/4/22 - 2007/4/29   2007/4/29 - 2007/5/6   2007/5/6 - 2007/5/13   2007/5/13 - 2007/5/20   2007/5/20 - 2007/5/27   2007/5/27 - 2007/6/3   2007/6/3 - 2007/6/10   2007/6/10 - 2007/6/17   2007/6/17 - 2007/6/24   2007/6/24 - 2007/7/1   2007/7/8 - 2007/7/15   2007/12/2 - 2007/12/9   2007/12/9 - 2007/12/16   2007/12/16 - 2007/12/23   2009/10/18 - 2009/10/25   2010/1/10 - 2010/1/17  

This page is powered by Blogger. Isn't yours?

订阅 博文 [Atom]