国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

PHP技巧:優化動態網頁技術PHP程序的12條技巧

2024-05-04 21:51:25
字體:
來源:轉載
供稿:網友

1、If a method can be static, declare it static. Speed improvement is by a factor of 4。

1、如果一個函數可以聲明為靜態的,那么就用靜態的,速度是改進的一個因素4。


2、# Avoid magic like __get, __set, __autoload

2、避免使用__get, __set, __autoload等魔術函數


3、require_once() is expensive

3、require_once()是相當昂貴的。


4、Use full paths in includes and requires, less time spent on resolving the OS paths.

4、用include和require時,盡量用全路徑,可以減少花在解決OS路徑的時間


5、If you need to find out the time when the scrīpt started executing, $_SERVER[’REQUEST_TIME’] is preferred to time()

5、如果你需要知道一個腳本的開始運行時間,用 $_SERVER[’REQUEST_TIME’]比用time()要好


6、See if you can use strncasecmp, strpbrk and stripos instead of regex

6、如果可以用strncasecmp, strpbrk and stripos就別用正則


7、preg_replace is faster than str_replace, but strtr is faster than preg_replace by a factor of 4

7、preg_replace比str_replace要快,但是strtr比preg_replace更快


8、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.

一些函數,比如字符串替換函數,接受數組和單個字符做為參數,并且如果你的參數列表不是很長,考慮寫一些冗余替換語句,每次傳送一個字符,代替一行代碼接受數組做為查找和替換的參數。


9、Error suppression with @ is very slow.

9、禁止錯誤輸出符號@是非常慢的。


10、$row[’id’] is 7 times faster than $row[id]

10、、$row[’id’]比 $row[id]快7倍


11、Error messages are expensive

11、錯誤信息是非常昂貴的


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.

12、不要在循環內部使用函數,比如: for ($x=0; $x < count($array); $x)。count()函數在每次循環中都會被調用。


對于模板,你是否在用smarty?這可能是保證把最經常訪問的頁面緩存起來的最快的方法了。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 巴马| 鹤岗市| 叙永县| 奉节县| 海安县| 司法| 大悟县| 彰化县| 镇江市| 霍林郭勒市| 泗水县| 甘洛县| 林芝县| 黄大仙区| 泾源县| 德令哈市| 百色市| 孝感市| 平舆县| 克山县| 高邮市| 旌德县| 哈巴河县| 涪陵区| 阿尔山市| 石屏县| 望奎县| 红安县| 保靖县| 当雄县| 旺苍县| 香港| 长岛县| 马尔康县| 拉萨市| 上杭县| 神池县| 玉林市| 澄城县| 象山县| 临沂市|