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

首頁 > 開發 > PHP > 正文

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

2024-05-04 23:02:51
字體:
來源:轉載
供稿:網友
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?這可能是保證把最經常訪問的頁面緩存起來的最快的方法了。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 汾阳市| 罗平县| 军事| 南阳市| 乌拉特后旗| 通州区| 屏东县| 上蔡县| 霞浦县| 奎屯市| 河东区| 虹口区| 班玛县| 涡阳县| 晴隆县| 永泰县| 定陶县| 和政县| 密云县| 枣庄市| 英超| 东乡| 西青区| 台东县| 三门峡市| 阳曲县| 双鸭山市| 宁波市| 陕西省| 嘉鱼县| 灵璧县| 新乡县| 青阳县| 绥芬河市| 永顺县| 富宁县| 博爱县| 香格里拉县| 新兴县| 兴安县| 雅江县|