日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > php教程 > 優化PHP代碼的四十三條建議(推薦)

優化PHP代碼的四十三條建議(推薦)

來源:程序員人生   發布時間:2014-06-03 22:11:44 閱讀次數:3269次

  1. If a method can be static, declare it static. Speed improvement is by a factor of 4. 如果一個方法可靜態化,就對它做靜態聲明。速率可提升至4倍。

  2. echo is faster than print. echo 比 print 快。

  3. Use echo’s multiple parameters instead of string concatenation. 使用echo的多重參數(譯注:指用逗號而不是句點)代替字符串連接。

  4. Set the maxvalue for your for-loops before and not in the loop. 在執行for循環之前確定最大循環數,不要每循環一次都計算最大值。

  5. Unset your variables to free memory, especially large arrays. 注銷那些不用的變量尤其是大數組,以便釋放內存。

  6. Avoid magic like __get, __set, __autoload 盡量避免使用__get,__set,__autoload。

  7. require_once() is expensive require_once()代價昂貴。

  8. Use full paths in includes and requires, less time spent on resolving the OS paths. 在包含文件時使用完整路徑,解析操作系統路徑所需的時間會更少。

  9. If you need to find out the time when the script started executing, $_SERVER[’REQUEST_TIME’] is preferred to time() 如果你想知道腳本開始執行(譯注:即服務器端收到客戶端請求)的時刻,使用$_SERVER[‘REQUEST_TIME’]要好于time()。

  10. See if you can use strncasecmp, strpbrk and stripos instead of regex. 檢查是否能用strncasecmp,strpbrk,stripos函數代替正則表達式完成相同功能。

  11. str_replace is faster than preg_replace, but strtr is faster than str_replace by a factor of 4. str_replace函數比preg_replace函數快,但strtr函數的效率是str_replace函數的四倍。

  12. If the function, such as string replacement function, accepts both arrays and single characters as arguments, and if your argument list is not too long, consider writing a few redundant replacement statements, passing one character at a time, instead of one line of code that accepts arrays as search and replace arguments. 如果一個字符串替換函數,可接受數組或字符作為參數,并且參數長度不太長,那么可以考慮額外寫一段替換代碼,使得每次傳遞參數是一個字符,而不是只寫一行代碼接受數組作為查詢和替換的參數。

  13. It’s better to use select statements than multi if, else if, statements. 使用選擇分支語句(譯注:即switch case)好于使用多個if,else if語句。

  14. Error suppression with @ is very slow. 用@屏蔽錯誤消息的做法非常低效。

  15. Turn on apache’s mod_deflate 打開apache的mod_deflate模塊。

  16. Close your database connections when you’re done with them. 數據庫連接當使用完畢時應關掉。

  17. $row[’id’] is 7 times faster than $row[id]. $row[‘id’]的效率是$row[id]的7倍。

  18. Error messages are expensive. 錯誤消息代價昂貴。

  19. Do not use functions inside of for loop, such as for ($x=0; $x < count($array); $x) The count() function gets called each time. 盡量不要在for循環中使用函數,比如for ($x=0; $x < count($array); $x)每循環一次都會調用count()函數。

生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: www.日韩.com| 日韩一级在线观看 | 国产精品久久久精品 | 国产a级大片 | 欧美精品免费在线观看 | 美女又爽又黄视频毛茸茸 | 91精品婷婷国产综合久久性色 | 米奇狠狠 | 日韩精品在线播放 | 亚洲精品视频在线观看免费 | 97精品视频在线播放 | 亚洲精品1 | 久久久久久免费毛片精品 | 91久久久久久久久久久 | 久久成人综合 | 欧美成人免费网站 | 五月婷婷六月激情 | 国产一区久久 | 天堂网在线最新版www中文网 | 欧美精品在线一区二区三区 | 韩国三级av | 欧美一级国产 | 青青av | 国产精品videossex| 亚洲精品美女久久久久99 | 亚洲第一网站 | a视频在线观看免费 | 亚洲高清中文字幕 | 国产视频黄色 | 毛片网站在线观看 | 久久99精品久久久久婷婷 | 日韩福利在线 | 欧美日韩999| 亚洲视频在线免费观看 | 夜夜福利 | 午夜免费激情 | 精品久久精品 | 国产欧美日韩一区二区三区 | 亚洲福利片 | 日韩一区二区在线看 | 国产成人精品一区二区三区视频 |